forked from zcws/node-feign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.d.ts
53 lines (49 loc) · 2.06 KB
/
global.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
interface Instance {
ip: string, //IP of instance
port: number, //Port of instance
weight?: number,
ephemeral?: boolean,
clusterName?: string
}
type Hosts = string[];
interface SubscribeInfo {
serviceName: string,
groupName?: string,
clusters?: string
}
/**
* Nacos服务发现组件
*/
export class NacosNamingClient {
constructor(config: { logger: typeof console, serverList: string | string[], namespace?: string })
ready: () => Promise<void>;
// Register an instance to service
registerInstance: (
serviceName: string, //Service name
instance: Instance, //Instance
groupName?: string // group name, default is DEFAULT_GROUP
) => Promise<void>;
// Delete instance from service.
deregisterInstance: (
serviceName: string, //Service name
instance: Instance, //Instance
groupName?: string // group name, default is DEFAULT_GROUP
) => Promise<void>;
// Query instance list of service.
getAllInstances: (
serviceName: string, //Service name
groupName?: string, //group name, default is DEFAULT_GROUP
clusters?: string, //Cluster names
subscribe?: boolean //whether subscribe the service, default is true
) => Promise<Hosts>;
// Get the status of mse server, 'UP' or 'DOWN'.
getServerStatus: () => "UP" | "DOWN";
subscribe: (
info: SubscribeInfo | string, //service info, if type is string, it's the serviceName
listener: (host: Hosts) => void //the listener function
) => void;
unSubscribe: (
info: SubscribeInfo | string, //service info, if type is string, it's the serviceName
listener: (host: Hosts) => void //the listener function
) => void;
}