-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.d.ts
124 lines (122 loc) · 3.95 KB
/
index.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export function sum(a: number, b: number): number
export interface ClientOptions {
/** Server Addr, e.g. address:port[,address:port],...] */
serverAddr: string
/** Namespace/Tenant */
namespace: string
/** AppName */
appName?: string
/** Username for Auth */
username?: string
/** Password for Auth */
password?: string
}
export interface NacosConfigResponse {
/** Namespace/Tenant */
namespace: string
/** DataId */
dataId: string
/** Group */
group: string
/** Content */
content: string
/** Content's Type; e.g. json,properties,xml,html,text,yaml */
contentType: string
/** Content's md5 */
md5: string
}
export interface NacosServiceInstance {
/** Instance Id */
instanceId?: string
/** Ip */
ip: string
/** Port */
port: number
/** Weight */
weight: number
/** Healthy or not */
healthy: boolean
/** Enabled ot not */
enabled: boolean
/** Ephemeral or not */
ephemeral: boolean
/** Cluster Name */
clusterName?: string
/** Service Name */
serviceName?: string
/** Metadata */
metadata: Record<string, string>
}
/** Client api of Nacos Config. */
export class NacosConfigClient {
/** Build a Config Client. */
constructor(clientOptions: ClientOptions)
/**
* Get config's content.
* If it fails, pay attention to err
*/
getConfig(dataId: string, group: string): string
/**
* Get NacosConfigResponse.
* If it fails, pay attention to err
*/
getConfigResp(dataId: string, group: string): NacosConfigResponse
/**
* Publish config.
* If it fails, pay attention to err
*/
publishConfig(dataId: string, group: string, content: string): boolean
/**
* Remove config.
* If it fails, pay attention to err
*/
removeConfig(dataId: string, group: string): boolean
/**
* Add NacosConfigChangeListener callback func, which listen the config change.
* If it fails, pay attention to err
*/
addListener(dataId: string, group: string, listener: (err: Error | null, value: NacosConfigResponse) => any): void
}
/** Client api of Nacos Naming. */
export class NacosNamingClient {
/** Build a Naming Client. */
constructor(clientOptions: ClientOptions)
/**
* Register instance.
* If it fails, pay attention to err
*/
registerInstance(serviceName: string, group: string, serviceInstance: NacosServiceInstance): void
/**
* Deregister instance.
* If it fails, pay attention to err
*/
deregisterInstance(serviceName: string, group: string, serviceInstance: NacosServiceInstance): void
/**
* Batch register instance, improve interaction efficiency.
* If it fails, pay attention to err
*/
batchRegisterInstance(serviceName: string, group: string, serviceInstances: Array<NacosServiceInstance>): void
/**
* Get all instances by service and group. default cluster=[], subscribe=true.
* If it fails, pay attention to err
*/
getAllInstances(serviceName: string, group: string, clusters?: Array<string> | undefined | null, subscribe?: boolean = true): Array<NacosServiceInstance>
/**
* Select instances whether healthy or not. default cluster=[], subscribe=true, healthy=true.
* If it fails, pay attention to err
*/
selectInstances(serviceName: string, group: string, clusters?: Array<string> | undefined | null, subscribe?: boolean = true, healthy?: boolean = true): Array<NacosServiceInstance>
/**
* Select one healthy instance. default cluster=[], subscribe=true.
* If it fails, pay attention to err
*/
selectOneHealthyInstance(serviceName: string, group: string, clusters?: Array<string> | undefined | null, subscribe?: boolean = true): NacosServiceInstance
/**
* Add NacosNamingEventListener callback func, which listen the instance change.
* If it fails, pay attention to err
*/
subscribe(serviceName: string, group: string, clusters: Array<string> | undefined | null, listener: (err: Error | null, value: Array<NacosServiceInstance>) => any): void
}