Skip to content

Commit

Permalink
feat: refactor type definitions, bringing in other vodyani toolkits t…
Browse files Browse the repository at this point in the history
…o combine information
  • Loading branch information
ChoGathK committed Aug 17, 2022
1 parent 5fcb217 commit dab874e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 35 deletions.
51 changes: 16 additions & 35 deletions src/common/interface/dynamic-data-source.ts
Original file line number Diff line number Diff line change
@@ -1,59 +1,40 @@
import { DeployAsyncClient, DeployClient, Method, PromiseMethod, RemoteSubscribe } from '../type';
import { DeployAsyncClient, DeployClient, Method, PromiseMethod } from '../type';

export interface Client<T = any> {
get: () => T;
close: Method<any>;
getInstance: Method<T>;
close: Method<void>;
}

export interface AsyncClient<T = any> {
get: () => T;
close: PromiseMethod<any>;
getInstance: Method<T>;
close: PromiseMethod<void>;
}

export interface ClientAdapter<T = any, O = any> {
getClient: (key: string) => Client<T>;
create: (options: O) => Client<T>;
}

export interface AsyncClientAdapter<T = any, O = any> {
getClient: (key: string) => AsyncClient<T>;
create: (options: O) => Promise<AsyncClient<T>>;
}

export interface IClientProxy<T = any, O = any> {
get: () => T;
getClient: () => Client<T>;

deploy: DeployClient<T, O>;
redeploy: (option: O) => void;

close: Method<void>;
}

export interface IAsyncClientProxy<T = any, O = any> {
get: () => T;
getClient: () => AsyncClient<T>;

deploy: DeployAsyncClient<T, O>;
redeploy: (option: O) => Promise<void>;

close: PromiseMethod<void>;
}

export interface ClientAdapter<T = any, O = any> {
connect: (key: string) => T;
create: (options: O) => Client<T>;
}

export interface AsyncClientAdapter<O = any, T = any> {
connect: (key: string) => T;
create: (options: O) => Promise<AsyncClient<T>>;
}

export interface DynamicDataSourceOptions {
key: string,
configKey: string,
args?: any[],
}

export interface RemoteConfigClient {
init: PromiseMethod<any>;
sync?: PromiseMethod<any>;
subscribe?: RemoteSubscribe;
close?: PromiseMethod<any>;
}

export interface RemoteConfigInfo<O = any, E = any> {
key: string;
options?: O;
extra?: E;
}
1 change: 1 addition & 0 deletions src/common/interface/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './dynamic-data-source';
export * from './manager';
export * from './monitor';
export * from './remote-config';
1 change: 1 addition & 0 deletions src/common/interface/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export interface WatchInfo {
key: any;
value: any;
callback: Method;
hashToken: string;
}
14 changes: 14 additions & 0 deletions src/common/interface/remote-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { PromiseMethod, RemoteSubscribe } from '../type';

export interface RemoteConfigClient {
init: PromiseMethod<any>;
sync?: PromiseMethod<any>;
subscribe?: RemoteSubscribe;
close?: PromiseMethod<any>;
}

export interface RemoteConfigInfo<O = any, E = any> {
key: string;
options?: O;
extra?: E;
}

0 comments on commit dab874e

Please sign in to comment.