nacos-sdk-rust-binding-node 0.4.0 → 0.5.3-BETA2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "WebSearch",
5
+ "WebFetch(domain:www.npmjs.com)",
6
+ "WebFetch(domain:crates.io)",
7
+ "Bash(npm view:*)",
8
+ "Bash(yarn install)",
9
+ "Bash(cargo check:*)",
10
+ "WebFetch(domain:github.com)",
11
+ "Bash(cargo doc:*)",
12
+ "Bash(grep:*)",
13
+ "Bash(npm run build)",
14
+ "WebFetch(domain:napi.rs)"
15
+ ]
16
+ }
17
+ }
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ConfPoetryConfig">
4
+ <option name="pathRules">
5
+ <list>
6
+ <option value=".*/config/[^/]+/[^/]+/((env)|(drm)|(log)|(meta)|(scheduler)|(serviceGroup)|(zdal)|(ci))/[^/]+" />
7
+ <option value=".*/config/[^/]+/dbSql/[^/]+" />
8
+ <option value=".*/conf/iac/[^/]+/((env)|(drm)|(log)|(meta)|(scheduler)|(serviceGroup)|(zdal)|(ci)|(sofamq)|(database))/[^/]+" />
9
+ <option value=".*/conf/iac/[^/]+/msg/(pub|sub)/[^/]+" />
10
+ </list>
11
+ </option>
12
+ </component>
13
+ </project>
@@ -0,0 +1,10 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
5
+ <Languages>
6
+ <language minSize="84" name="Rust" />
7
+ </Languages>
8
+ </inspection_tool>
9
+ </profile>
10
+ </component>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/nacos-sdk-rust-binding-node.iml" filepath="$PROJECT_DIR$/.idea/nacos-sdk-rust-binding-node.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$">
6
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7
+ <excludeFolder url="file://$MODULE_DIR$/target" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
package/Cargo.toml CHANGED
@@ -1,9 +1,10 @@
1
1
  [package]
2
- edition = "2021"
3
2
  name = "nacos-sdk-rust-binding-node"
4
- version = "0.4.0"
5
- authors = ["CheirshCai <785427346@qq.com>"]
3
+ version = "0.5.3"
4
+ edition = "2024"
6
5
  license = "Apache-2.0"
6
+ publish = false
7
+ authors = ["CheirshCai <785427346@qq.com>"]
7
8
  readme = "README.md"
8
9
  repository = "https://github.com/opc-source/nacos-sdk-rust-binding-node"
9
10
  description = "nacos-sdk-rust binding for NodeJs with napi."
@@ -18,13 +19,9 @@ crate-type = ["cdylib"]
18
19
  napi = { version = "2", default-features = false, features = ["napi4", "async"] }
19
20
  napi-derive = "2"
20
21
 
21
- nacos-sdk = { version = "0.4.0", features = ["default"] }
22
- #nacos-sdk = { git = "https://github.com/nacos-group/nacos-sdk-rust.git", branch = "main", features = ["default"] }
22
+ #nacos-sdk = { version = "0.5.3", features = ["default", "auth-by-aliyun", "tracing-log"] }
23
+ nacos-sdk = { git = "https://github.com/nacos-group/nacos-sdk-rust.git", branch = "main", features = ["default", "auth-by-aliyun", "tracing-log"] }
23
24
 
24
- tracing-subscriber = { version = "0.3", features = ["default"] }
25
- #tracing-subscriber = { version = "0.3", features = ["env-filter", "local-time"] } # occur `<unknown time>`
26
- tracing-appender = "0.2"
27
- lazy_static = "1.4.0"
28
25
  async-trait = "0.1"
29
26
 
30
27
  [build-dependencies]
package/example/naming.js CHANGED
@@ -41,11 +41,11 @@ function sleep(time){
41
41
  const serviceName = 'TestServiceName';
42
42
  const group = 'LOVE';
43
43
 
44
- nacos_naming_client.subscribe(serviceName, group, null, (err, instance_array) => { console.log('subscribe instance_array => ' + JSON.stringify(instance_array)) });
44
+ await nacos_naming_client.subscribe(serviceName, group, null, (err, instance_array) => { console.log('subscribe instance_array => ' + JSON.stringify(instance_array)) });
45
45
  await sleep(2000);
46
46
 
47
47
  console.log('--------- registerInstance instance1 ------------');
48
- nacos_naming_client.registerInstance(serviceName, group, instance1); // If it fails, pay attention to err
48
+ await nacos_naming_client.registerInstance(serviceName, group, instance1); // If it fails, pay attention to err
49
49
  await sleep(1000);
50
50
 
51
51
  console.log('--------- get all instances 1 ------------');
@@ -55,7 +55,7 @@ function sleep(time){
55
55
  await sleep(1000);
56
56
 
57
57
  console.log('--------- batchRegisterInstance instance2 ------------');
58
- nacos_naming_client.batchRegisterInstance(serviceName, group, [instance1, instance2]); // If it fails, pay attention to err
58
+ await nacos_naming_client.batchRegisterInstance(serviceName, group, [instance1, instance2]); // If it fails, pay attention to err
59
59
  await sleep(1000);
60
60
 
61
61
  console.log('--------- get all instances 2 ------------');
package/index.d.ts CHANGED
@@ -1,91 +1,9 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
1
  /* auto-generated by NAPI-RS */
5
-
6
- export function sum(a: number, b: number): number
7
- export interface ClientOptions {
8
- /** Server Addr, e.g. address:port[,address:port],...] */
9
- serverAddr: string
10
- /** Namespace/Tenant */
11
- namespace: string
12
- /** AppName */
13
- appName?: string
14
- /** Username for Auth */
15
- username?: string
16
- /** Password for Auth */
17
- password?: string
18
- /** naming push_empty_protection, default true */
19
- namingPushEmptyProtection?: boolean
20
- /** naming load_cache_at_start, default false */
21
- namingLoadCacheAtStart?: boolean
22
- }
23
- export interface NacosConfigResponse {
24
- /** Namespace/Tenant */
25
- namespace: string
26
- /** DataId */
27
- dataId: string
28
- /** Group */
29
- group: string
30
- /** Content */
31
- content: string
32
- /** Content's Type; e.g. json,properties,xml,html,text,yaml */
33
- contentType: string
34
- /** Content's md5 */
35
- md5: string
36
- }
37
- export interface NacosServiceInstance {
38
- /** Instance Id */
39
- instanceId?: string
40
- /** Ip */
41
- ip: string
42
- /** Port */
43
- port: number
44
- /** Weight, default 1.0 */
45
- weight?: number
46
- /** Healthy or not, default true */
47
- healthy?: boolean
48
- /** Enabled ot not, default true */
49
- enabled?: boolean
50
- /** Ephemeral or not, default true */
51
- ephemeral?: boolean
52
- /** Cluster Name, default 'DEFAULT' */
53
- clusterName?: string
54
- /** Service Name */
55
- serviceName?: string
56
- /** Metadata, default '{}' */
57
- metadata?: Record<string, string>
58
- }
59
- /** ConfigReq for [`ConfigFilter`] */
60
- export interface NacosConfigReq {
61
- /** DataId */
62
- dataId: string
63
- /** Group */
64
- group: string
65
- /** Namespace/Tenant */
66
- namespace: string
67
- /** Content */
68
- content: string
69
- /** Content's Encrypted Data Key. */
70
- encryptedDataKey: string
71
- }
72
- /** ConfigResp for [`ConfigFilter`] */
73
- export interface NacosConfigResp {
74
- /** DataId */
75
- dataId: string
76
- /** Group */
77
- group: string
78
- /** Namespace/Tenant */
79
- namespace: string
80
- /** Content */
81
- content: string
82
- /** Content's Encrypted Data Key. */
83
- encryptedDataKey: string
84
- }
2
+ /* eslint-disable */
85
3
  /** Client api of Nacos Config. */
86
- export class NacosConfigClient {
4
+ export declare class NacosConfigClient {
87
5
  /** Build a Config Client. */
88
- constructor(clientOptions: ClientOptions, configFilter?: (err: Error | null, arg0?: NacosConfigReq | undefined | null, arg1?: NacosConfigResp | undefined | null) => any | undefined | null)
6
+ constructor(clientOptions: ClientOptions, configFilter?: (((err: Error | null, arg0?: NacosConfigReq | undefined | null, arg1?: NacosConfigResp | undefined | null) => any)) | undefined | null)
89
7
  /**
90
8
  * Get config's content.
91
9
  * If it fails, pay attention to err
@@ -110,16 +28,17 @@ export class NacosConfigClient {
110
28
  * Add NacosConfigChangeListener callback func, which listen the config change.
111
29
  * If it fails, pay attention to err
112
30
  */
113
- addListener(dataId: string, group: string, listener: (err: Error | null, arg: NacosConfigResponse) => any): Promise<void>
31
+ addListener(dataId: string, group: string, listener: ((err: Error | null, arg: NacosConfigResponse) => any)): Promise<void>
114
32
  /**
115
33
  * Remove NacosConfigChangeListener callback func, but noop....
116
34
  * The logic is not implemented internally, and only APIs are provided as compatibility.
117
35
  * Users maybe do not need it? Not removing the listener is not a big problem, Sorry!
118
36
  */
119
- removeListener(dataId: string, group: string, listener: (err: Error | null, arg: NacosConfigResponse) => any): Promise<void>
37
+ removeListener(dataId: string, group: string, listener: ((err: Error | null, arg: NacosConfigResponse) => any)): Promise<void>
120
38
  }
39
+
121
40
  /** Client api of Nacos Naming. */
122
- export class NacosNamingClient {
41
+ export declare class NacosNamingClient {
123
42
  /** Build a Naming Client. */
124
43
  constructor(clientOptions: ClientOptions)
125
44
  /**
@@ -156,11 +75,102 @@ export class NacosNamingClient {
156
75
  * Add NacosNamingEventListener callback func, which listen the instance change.
157
76
  * If it fails, pay attention to err
158
77
  */
159
- subscribe(serviceName: string, group: string, clusters: Array<string> | undefined | null, listener: (err: Error | null, arg: Array<NacosServiceInstance>) => any): Promise<void>
78
+ subscribe(serviceName: string, group: string, clusters: Array<string> | undefined | null, listener: ((err: Error | null, arg: Array<NacosServiceInstance>) => any)): Promise<void>
160
79
  /**
161
80
  * Remove NacosNamingEventListener callback func, but noop....
162
81
  * The logic is not implemented internally, and only APIs are provided as compatibility.
163
82
  * Users maybe do not need it? Not removing the subscription is not a big problem, Sorry!
164
83
  */
165
- unSubscribe(serviceName: string, group: string, clusters: Array<string> | undefined | null, listener: (err: Error | null, arg: Array<NacosServiceInstance>) => any): Promise<void>
84
+ unSubscribe(serviceName: string, group: string, clusters: Array<string> | undefined | null, listener: ((err: Error | null, arg: Array<NacosServiceInstance>) => any)): Promise<void>
166
85
  }
86
+
87
+ export interface ClientOptions {
88
+ /** Server Addr, e.g. address:port[,address:port],...] */
89
+ serverAddr: string
90
+ /** Namespace/Tenant */
91
+ namespace: string
92
+ /** AppName */
93
+ appName?: string
94
+ /** Username for Auth, Login by Http with Token */
95
+ username?: string
96
+ /** Password for Auth, Login by Http with Token */
97
+ password?: string
98
+ /** Access_Key for Auth, Login by Aliyun Ram */
99
+ accessKey?: string
100
+ /** Access_Secret for Auth, Login by Aliyun Ram */
101
+ accessSecret?: string
102
+ /** Signature_Region_Id for Auth, Login by Aliyun Ram */
103
+ signatureRegionId?: string
104
+ /** naming push_empty_protection, default true */
105
+ namingPushEmptyProtection?: boolean
106
+ /** naming load_cache_at_start, default false */
107
+ namingLoadCacheAtStart?: boolean
108
+ }
109
+
110
+ /** ConfigReq for [`ConfigFilter`] */
111
+ export interface NacosConfigReq {
112
+ /** DataId */
113
+ dataId: string
114
+ /** Group */
115
+ group: string
116
+ /** Namespace/Tenant */
117
+ namespace: string
118
+ /** Content */
119
+ content: string
120
+ /** Content's Encrypted Data Key. */
121
+ encryptedDataKey: string
122
+ }
123
+
124
+ /** ConfigResp for [`ConfigFilter`] */
125
+ export interface NacosConfigResp {
126
+ /** DataId */
127
+ dataId: string
128
+ /** Group */
129
+ group: string
130
+ /** Namespace/Tenant */
131
+ namespace: string
132
+ /** Content */
133
+ content: string
134
+ /** Content's Encrypted Data Key. */
135
+ encryptedDataKey: string
136
+ }
137
+
138
+ export interface NacosConfigResponse {
139
+ /** Namespace/Tenant */
140
+ namespace: string
141
+ /** DataId */
142
+ dataId: string
143
+ /** Group */
144
+ group: string
145
+ /** Content */
146
+ content: string
147
+ /** Content's Type; e.g. json,properties,xml,html,text,yaml */
148
+ contentType: string
149
+ /** Content's md5 */
150
+ md5: string
151
+ }
152
+
153
+ export interface NacosServiceInstance {
154
+ /** Instance Id */
155
+ instanceId?: string
156
+ /** Ip */
157
+ ip: string
158
+ /** Port */
159
+ port: number
160
+ /** Weight, default 1.0 */
161
+ weight?: number
162
+ /** Healthy or not, default true */
163
+ healthy?: boolean
164
+ /** Enabled ot not, default true */
165
+ enabled?: boolean
166
+ /** Ephemeral or not, default true */
167
+ ephemeral?: boolean
168
+ /** Cluster Name, default 'DEFAULT' */
169
+ clusterName?: string
170
+ /** Service Name */
171
+ serviceName?: string
172
+ /** Metadata, default '{}' */
173
+ metadata?: Record<string, string>
174
+ }
175
+
176
+ export declare function sum(a: number, b: number): number