-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change the interface convention for the remote configuration ce…
…nter
- Loading branch information
Showing
4 changed files
with
121 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,72 @@ | ||
export interface Client<T = any> { | ||
/** | ||
* Gets the client instance object. | ||
* | ||
* @publicApi | ||
*/ | ||
getInstance: () => T; | ||
/** | ||
* Close the client instance. | ||
* | ||
* @publicApi | ||
*/ | ||
close: (...args: any[]) => void; | ||
} | ||
|
||
export interface AsyncClient<T = any> { | ||
/** | ||
* Gets the client instance object. | ||
* | ||
* @publicApi | ||
*/ | ||
getInstance: () => T; | ||
/** | ||
* Close the client instance. | ||
* | ||
* @publicApi | ||
*/ | ||
close: (...args: any[]) => Promise<void>; | ||
} | ||
|
||
export interface ClientAdapter<T = any, O = any> { | ||
getClient: (key: string) => Client<T>; | ||
/** | ||
* Creating the client. | ||
* | ||
* @publicApi | ||
*/ | ||
create: (options: O) => Client<T>; | ||
/** | ||
* Gets the client. | ||
* | ||
* @publicApi | ||
*/ | ||
getClient: (key: string) => Client<T>; | ||
/** | ||
* Gets the client instance object. | ||
* | ||
* @publicApi | ||
*/ | ||
getInstance: (key: string) => T; | ||
|
||
} | ||
|
||
export interface AsyncClientAdapter<T = any, O = any> { | ||
getClient: (key: string) => AsyncClient<T>; | ||
/** | ||
* Creating the client. | ||
* | ||
* @publicApi | ||
*/ | ||
create: (options: O) => Promise<AsyncClient<T>>; | ||
/** | ||
* Gets the client. | ||
* | ||
* @publicApi | ||
*/ | ||
getClient: (key: string) => AsyncClient<T>; | ||
/** | ||
* Gets the client instance object. | ||
* | ||
* @publicApi | ||
*/ | ||
getInstance: (key: string) => T; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,37 @@ | ||
export interface RemoteConfigClient { | ||
/** | ||
* Close the remote configuration center. | ||
* | ||
* @publicApi | ||
*/ | ||
close?: (...args: any[]) => Promise<any>; | ||
/** | ||
* Periodic synchronization of configuration information (polling). | ||
* | ||
* @publicApi | ||
*/ | ||
sync?: () => Promise<any>; | ||
/** | ||
* Subscribe to configuration information (callbacks or hot updates). | ||
* | ||
* @publicApi | ||
*/ | ||
subscribe?: () => Promise<any>; | ||
/** | ||
* Use customize arguments to initialize the remote configuration center. | ||
* | ||
* @publicApi | ||
*/ | ||
init: (...args: any[]) => Promise<Partial<any>>; | ||
sync: (...args: any[]) => Promise<Partial<any>>; | ||
subscribe?: (key: string, callback: (value: any) => any, ...args: any[]) => Promise<void>; | ||
} | ||
|
||
export interface RemoteConfigInfo<T = any> { | ||
/** | ||
* Key in the remote configuration center. | ||
*/ | ||
key: string; | ||
/** | ||
* Indicates the actual configuration value. | ||
*/ | ||
value?: T; | ||
} |