nacos-sdk-rust-binding-node 0.4.2 → 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.
- package/.claude/settings.local.json +17 -0
- package/.idea/ConfPoetryConfig.xml +13 -0
- package/.idea/inspectionProfiles/Project_Default.xml +10 -0
- package/.idea/modules.xml +8 -0
- package/.idea/nacos-sdk-rust-binding-node.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/Cargo.toml +6 -9
- package/example/naming.js +3 -3
- package/index.d.ts +100 -96
- package/index.js +524 -202
- package/package.json +12 -15
- package/src/config.rs +2 -5
- package/src/lib.rs +0 -34
- package/src/naming.rs +2 -5
|
@@ -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
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.
|
|
5
|
-
|
|
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.
|
|
22
|
-
|
|
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,97 +1,9 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
|
|
4
1
|
/* auto-generated by NAPI-RS */
|
|
5
|
-
|
|
6
|
-
export declare 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, Login by Http with Token */
|
|
15
|
-
username?: string
|
|
16
|
-
/** Password for Auth, Login by Http with Token */
|
|
17
|
-
password?: string
|
|
18
|
-
/** Access_Key for Auth, Login by Aliyun Ram */
|
|
19
|
-
accessKey?: string
|
|
20
|
-
/** Access_Secret for Auth, Login by Aliyun Ram */
|
|
21
|
-
accessSecret?: string
|
|
22
|
-
/** Signature_Region_Id for Auth, Login by Aliyun Ram */
|
|
23
|
-
signatureRegionId?: string
|
|
24
|
-
/** naming push_empty_protection, default true */
|
|
25
|
-
namingPushEmptyProtection?: boolean
|
|
26
|
-
/** naming load_cache_at_start, default false */
|
|
27
|
-
namingLoadCacheAtStart?: boolean
|
|
28
|
-
}
|
|
29
|
-
export interface NacosConfigResponse {
|
|
30
|
-
/** Namespace/Tenant */
|
|
31
|
-
namespace: string
|
|
32
|
-
/** DataId */
|
|
33
|
-
dataId: string
|
|
34
|
-
/** Group */
|
|
35
|
-
group: string
|
|
36
|
-
/** Content */
|
|
37
|
-
content: string
|
|
38
|
-
/** Content's Type; e.g. json,properties,xml,html,text,yaml */
|
|
39
|
-
contentType: string
|
|
40
|
-
/** Content's md5 */
|
|
41
|
-
md5: string
|
|
42
|
-
}
|
|
43
|
-
export interface NacosServiceInstance {
|
|
44
|
-
/** Instance Id */
|
|
45
|
-
instanceId?: string
|
|
46
|
-
/** Ip */
|
|
47
|
-
ip: string
|
|
48
|
-
/** Port */
|
|
49
|
-
port: number
|
|
50
|
-
/** Weight, default 1.0 */
|
|
51
|
-
weight?: number
|
|
52
|
-
/** Healthy or not, default true */
|
|
53
|
-
healthy?: boolean
|
|
54
|
-
/** Enabled ot not, default true */
|
|
55
|
-
enabled?: boolean
|
|
56
|
-
/** Ephemeral or not, default true */
|
|
57
|
-
ephemeral?: boolean
|
|
58
|
-
/** Cluster Name, default 'DEFAULT' */
|
|
59
|
-
clusterName?: string
|
|
60
|
-
/** Service Name */
|
|
61
|
-
serviceName?: string
|
|
62
|
-
/** Metadata, default '{}' */
|
|
63
|
-
metadata?: Record<string, string>
|
|
64
|
-
}
|
|
65
|
-
/** ConfigReq for [`ConfigFilter`] */
|
|
66
|
-
export interface NacosConfigReq {
|
|
67
|
-
/** DataId */
|
|
68
|
-
dataId: string
|
|
69
|
-
/** Group */
|
|
70
|
-
group: string
|
|
71
|
-
/** Namespace/Tenant */
|
|
72
|
-
namespace: string
|
|
73
|
-
/** Content */
|
|
74
|
-
content: string
|
|
75
|
-
/** Content's Encrypted Data Key. */
|
|
76
|
-
encryptedDataKey: string
|
|
77
|
-
}
|
|
78
|
-
/** ConfigResp for [`ConfigFilter`] */
|
|
79
|
-
export interface NacosConfigResp {
|
|
80
|
-
/** DataId */
|
|
81
|
-
dataId: string
|
|
82
|
-
/** Group */
|
|
83
|
-
group: string
|
|
84
|
-
/** Namespace/Tenant */
|
|
85
|
-
namespace: string
|
|
86
|
-
/** Content */
|
|
87
|
-
content: string
|
|
88
|
-
/** Content's Encrypted Data Key. */
|
|
89
|
-
encryptedDataKey: string
|
|
90
|
-
}
|
|
2
|
+
/* eslint-disable */
|
|
91
3
|
/** Client api of Nacos Config. */
|
|
92
|
-
export class NacosConfigClient {
|
|
4
|
+
export declare class NacosConfigClient {
|
|
93
5
|
/** Build a Config Client. */
|
|
94
|
-
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)
|
|
95
7
|
/**
|
|
96
8
|
* Get config's content.
|
|
97
9
|
* If it fails, pay attention to err
|
|
@@ -116,16 +28,17 @@ export class NacosConfigClient {
|
|
|
116
28
|
* Add NacosConfigChangeListener callback func, which listen the config change.
|
|
117
29
|
* If it fails, pay attention to err
|
|
118
30
|
*/
|
|
119
|
-
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>
|
|
120
32
|
/**
|
|
121
33
|
* Remove NacosConfigChangeListener callback func, but noop....
|
|
122
34
|
* The logic is not implemented internally, and only APIs are provided as compatibility.
|
|
123
35
|
* Users maybe do not need it? Not removing the listener is not a big problem, Sorry!
|
|
124
36
|
*/
|
|
125
|
-
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>
|
|
126
38
|
}
|
|
39
|
+
|
|
127
40
|
/** Client api of Nacos Naming. */
|
|
128
|
-
export class NacosNamingClient {
|
|
41
|
+
export declare class NacosNamingClient {
|
|
129
42
|
/** Build a Naming Client. */
|
|
130
43
|
constructor(clientOptions: ClientOptions)
|
|
131
44
|
/**
|
|
@@ -162,11 +75,102 @@ export class NacosNamingClient {
|
|
|
162
75
|
* Add NacosNamingEventListener callback func, which listen the instance change.
|
|
163
76
|
* If it fails, pay attention to err
|
|
164
77
|
*/
|
|
165
|
-
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>
|
|
166
79
|
/**
|
|
167
80
|
* Remove NacosNamingEventListener callback func, but noop....
|
|
168
81
|
* The logic is not implemented internally, and only APIs are provided as compatibility.
|
|
169
82
|
* Users maybe do not need it? Not removing the subscription is not a big problem, Sorry!
|
|
170
83
|
*/
|
|
171
|
-
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>
|
|
172
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
|
package/index.js
CHANGED
|
@@ -1,259 +1,581 @@
|
|
|
1
|
-
|
|
1
|
+
// prettier-ignore
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
// @ts-nocheck
|
|
5
4
|
/* auto-generated by NAPI-RS */
|
|
6
5
|
|
|
7
|
-
const {
|
|
8
|
-
|
|
6
|
+
const { readFileSync } = require('node:fs')
|
|
7
|
+
let nativeBinding = null
|
|
8
|
+
const loadErrors = []
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const isMusl = () => {
|
|
11
|
+
let musl = false
|
|
12
|
+
if (process.platform === 'linux') {
|
|
13
|
+
musl = isMuslFromFilesystem()
|
|
14
|
+
if (musl === null) {
|
|
15
|
+
musl = isMuslFromReport()
|
|
16
|
+
}
|
|
17
|
+
if (musl === null) {
|
|
18
|
+
musl = isMuslFromChildProcess()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return musl
|
|
22
|
+
}
|
|
11
23
|
|
|
12
|
-
|
|
13
|
-
let localFileExisted = false
|
|
14
|
-
let loadError = null
|
|
24
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
15
25
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
const isMuslFromFilesystem = () => {
|
|
27
|
+
try {
|
|
28
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
29
|
+
} catch {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const isMuslFromReport = () => {
|
|
35
|
+
let report = null
|
|
36
|
+
if (typeof process.report?.getReport === 'function') {
|
|
37
|
+
process.report.excludeNetwork = true
|
|
38
|
+
report = process.report.getReport()
|
|
39
|
+
}
|
|
40
|
+
if (!report) {
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
47
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
23
48
|
return true
|
|
24
49
|
}
|
|
25
|
-
} else {
|
|
26
|
-
const { glibcVersionRuntime } = process.report.getReport().header
|
|
27
|
-
return !glibcVersionRuntime
|
|
28
50
|
}
|
|
51
|
+
return false
|
|
29
52
|
}
|
|
30
53
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
const isMuslFromChildProcess = () => {
|
|
55
|
+
try {
|
|
56
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
57
|
+
} catch (e) {
|
|
58
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function requireNative() {
|
|
64
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
65
|
+
try {
|
|
66
|
+
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
loadErrors.push(err)
|
|
69
|
+
}
|
|
70
|
+
} else if (process.platform === 'android') {
|
|
71
|
+
if (process.arch === 'arm64') {
|
|
72
|
+
try {
|
|
73
|
+
return require('./nacos-sdk-rust-binding-node.android-arm64.node')
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadErrors.push(e)
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const binding = require('nacos-sdk-rust-binding-node-android-arm64')
|
|
79
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-android-arm64/package.json').version
|
|
80
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
|
+
}
|
|
83
|
+
return binding
|
|
84
|
+
} catch (e) {
|
|
85
|
+
loadErrors.push(e)
|
|
86
|
+
}
|
|
87
|
+
} else if (process.arch === 'arm') {
|
|
88
|
+
try {
|
|
89
|
+
return require('./nacos-sdk-rust-binding-node.android-arm-eabi.node')
|
|
90
|
+
} catch (e) {
|
|
91
|
+
loadErrors.push(e)
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const binding = require('nacos-sdk-rust-binding-node-android-arm-eabi')
|
|
95
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-android-arm-eabi/package.json').version
|
|
96
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
|
+
}
|
|
99
|
+
return binding
|
|
100
|
+
} catch (e) {
|
|
101
|
+
loadErrors.push(e)
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
105
|
+
}
|
|
106
|
+
} else if (process.platform === 'win32') {
|
|
107
|
+
if (process.arch === 'x64') {
|
|
108
|
+
if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
|
|
36
109
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
110
|
+
return require('./nacos-sdk-rust-binding-node.win32-x64-gnu.node')
|
|
111
|
+
} catch (e) {
|
|
112
|
+
loadErrors.push(e)
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const binding = require('nacos-sdk-rust-binding-node-win32-x64-gnu')
|
|
116
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-win32-x64-gnu/package.json').version
|
|
117
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
|
+
}
|
|
120
|
+
return binding
|
|
121
|
+
} catch (e) {
|
|
122
|
+
loadErrors.push(e)
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
try {
|
|
126
|
+
return require('./nacos-sdk-rust-binding-node.win32-x64-msvc.node')
|
|
127
|
+
} catch (e) {
|
|
128
|
+
loadErrors.push(e)
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const binding = require('nacos-sdk-rust-binding-node-win32-x64-msvc')
|
|
132
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-win32-x64-msvc/package.json').version
|
|
133
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
|
+
}
|
|
136
|
+
return binding
|
|
137
|
+
} catch (e) {
|
|
138
|
+
loadErrors.push(e)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} else if (process.arch === 'ia32') {
|
|
142
|
+
try {
|
|
143
|
+
return require('./nacos-sdk-rust-binding-node.win32-ia32-msvc.node')
|
|
144
|
+
} catch (e) {
|
|
145
|
+
loadErrors.push(e)
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
const binding = require('nacos-sdk-rust-binding-node-win32-ia32-msvc')
|
|
149
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-win32-ia32-msvc/package.json').version
|
|
150
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
|
+
}
|
|
153
|
+
return binding
|
|
154
|
+
} catch (e) {
|
|
155
|
+
loadErrors.push(e)
|
|
156
|
+
}
|
|
157
|
+
} else if (process.arch === 'arm64') {
|
|
158
|
+
try {
|
|
159
|
+
return require('./nacos-sdk-rust-binding-node.win32-arm64-msvc.node')
|
|
160
|
+
} catch (e) {
|
|
161
|
+
loadErrors.push(e)
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const binding = require('nacos-sdk-rust-binding-node-win32-arm64-msvc')
|
|
165
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-win32-arm64-msvc/package.json').version
|
|
166
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
|
+
}
|
|
169
|
+
return binding
|
|
170
|
+
} catch (e) {
|
|
171
|
+
loadErrors.push(e)
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
175
|
+
}
|
|
176
|
+
} else if (process.platform === 'darwin') {
|
|
177
|
+
try {
|
|
178
|
+
return require('./nacos-sdk-rust-binding-node.darwin-universal.node')
|
|
179
|
+
} catch (e) {
|
|
180
|
+
loadErrors.push(e)
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
const binding = require('nacos-sdk-rust-binding-node-darwin-universal')
|
|
184
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-darwin-universal/package.json').version
|
|
185
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
|
+
}
|
|
188
|
+
return binding
|
|
189
|
+
} catch (e) {
|
|
190
|
+
loadErrors.push(e)
|
|
191
|
+
}
|
|
192
|
+
if (process.arch === 'x64') {
|
|
193
|
+
try {
|
|
194
|
+
return require('./nacos-sdk-rust-binding-node.darwin-x64.node')
|
|
195
|
+
} catch (e) {
|
|
196
|
+
loadErrors.push(e)
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
const binding = require('nacos-sdk-rust-binding-node-darwin-x64')
|
|
200
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-darwin-x64/package.json').version
|
|
201
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
|
+
}
|
|
204
|
+
return binding
|
|
205
|
+
} catch (e) {
|
|
206
|
+
loadErrors.push(e)
|
|
207
|
+
}
|
|
208
|
+
} else if (process.arch === 'arm64') {
|
|
209
|
+
try {
|
|
210
|
+
return require('./nacos-sdk-rust-binding-node.darwin-arm64.node')
|
|
211
|
+
} catch (e) {
|
|
212
|
+
loadErrors.push(e)
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
const binding = require('nacos-sdk-rust-binding-node-darwin-arm64')
|
|
216
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-darwin-arm64/package.json').version
|
|
217
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
|
+
}
|
|
220
|
+
return binding
|
|
221
|
+
} catch (e) {
|
|
222
|
+
loadErrors.push(e)
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
226
|
+
}
|
|
227
|
+
} else if (process.platform === 'freebsd') {
|
|
228
|
+
if (process.arch === 'x64') {
|
|
229
|
+
try {
|
|
230
|
+
return require('./nacos-sdk-rust-binding-node.freebsd-x64.node')
|
|
231
|
+
} catch (e) {
|
|
232
|
+
loadErrors.push(e)
|
|
233
|
+
}
|
|
234
|
+
try {
|
|
235
|
+
const binding = require('nacos-sdk-rust-binding-node-freebsd-x64')
|
|
236
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-freebsd-x64/package.json').version
|
|
237
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
|
+
}
|
|
240
|
+
return binding
|
|
241
|
+
} catch (e) {
|
|
242
|
+
loadErrors.push(e)
|
|
243
|
+
}
|
|
244
|
+
} else if (process.arch === 'arm64') {
|
|
245
|
+
try {
|
|
246
|
+
return require('./nacos-sdk-rust-binding-node.freebsd-arm64.node')
|
|
247
|
+
} catch (e) {
|
|
248
|
+
loadErrors.push(e)
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
const binding = require('nacos-sdk-rust-binding-node-freebsd-arm64')
|
|
252
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-freebsd-arm64/package.json').version
|
|
253
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
|
+
}
|
|
256
|
+
return binding
|
|
257
|
+
} catch (e) {
|
|
258
|
+
loadErrors.push(e)
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
262
|
+
}
|
|
263
|
+
} else if (process.platform === 'linux') {
|
|
264
|
+
if (process.arch === 'x64') {
|
|
265
|
+
if (isMusl()) {
|
|
266
|
+
try {
|
|
267
|
+
return require('./nacos-sdk-rust-binding-node.linux-x64-musl.node')
|
|
42
268
|
} catch (e) {
|
|
43
|
-
|
|
269
|
+
loadErrors.push(e)
|
|
44
270
|
}
|
|
45
|
-
break
|
|
46
|
-
case 'arm':
|
|
47
|
-
localFileExisted = existsSync(join(__dirname, 'nacos-sdk-rust-binding-node.android-arm-eabi.node'))
|
|
48
271
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
272
|
+
const binding = require('nacos-sdk-rust-binding-node-linux-x64-musl')
|
|
273
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-linux-x64-musl/package.json').version
|
|
274
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
53
276
|
}
|
|
277
|
+
return binding
|
|
54
278
|
} catch (e) {
|
|
55
|
-
|
|
279
|
+
loadErrors.push(e)
|
|
56
280
|
}
|
|
57
|
-
|
|
58
|
-
default:
|
|
59
|
-
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
60
|
-
}
|
|
61
|
-
break
|
|
62
|
-
case 'win32':
|
|
63
|
-
switch (arch) {
|
|
64
|
-
case 'x64':
|
|
65
|
-
localFileExisted = existsSync(
|
|
66
|
-
join(__dirname, 'nacos-sdk-rust-binding-node.win32-x64-msvc.node')
|
|
67
|
-
)
|
|
281
|
+
} else {
|
|
68
282
|
try {
|
|
69
|
-
|
|
70
|
-
nativeBinding = require('./nacos-sdk-rust-binding-node.win32-x64-msvc.node')
|
|
71
|
-
} else {
|
|
72
|
-
nativeBinding = require('nacos-sdk-rust-binding-node-win32-x64-msvc')
|
|
73
|
-
}
|
|
283
|
+
return require('./nacos-sdk-rust-binding-node.linux-x64-gnu.node')
|
|
74
284
|
} catch (e) {
|
|
75
|
-
|
|
285
|
+
loadErrors.push(e)
|
|
76
286
|
}
|
|
77
|
-
break
|
|
78
|
-
case 'ia32':
|
|
79
|
-
localFileExisted = existsSync(
|
|
80
|
-
join(__dirname, 'nacos-sdk-rust-binding-node.win32-ia32-msvc.node')
|
|
81
|
-
)
|
|
82
287
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
288
|
+
const binding = require('nacos-sdk-rust-binding-node-linux-x64-gnu')
|
|
289
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-linux-x64-gnu/package.json').version
|
|
290
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
87
292
|
}
|
|
293
|
+
return binding
|
|
88
294
|
} catch (e) {
|
|
89
|
-
|
|
295
|
+
loadErrors.push(e)
|
|
90
296
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
join(__dirname, 'nacos-sdk-rust-binding-node.win32-arm64-msvc.node')
|
|
95
|
-
)
|
|
297
|
+
}
|
|
298
|
+
} else if (process.arch === 'arm64') {
|
|
299
|
+
if (isMusl()) {
|
|
96
300
|
try {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
301
|
+
return require('./nacos-sdk-rust-binding-node.linux-arm64-musl.node')
|
|
302
|
+
} catch (e) {
|
|
303
|
+
loadErrors.push(e)
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
const binding = require('nacos-sdk-rust-binding-node-linux-arm64-musl')
|
|
307
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-linux-arm64-musl/package.json').version
|
|
308
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
101
310
|
}
|
|
311
|
+
return binding
|
|
102
312
|
} catch (e) {
|
|
103
|
-
|
|
313
|
+
loadErrors.push(e)
|
|
104
314
|
}
|
|
105
|
-
break
|
|
106
|
-
default:
|
|
107
|
-
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
108
|
-
}
|
|
109
|
-
break
|
|
110
|
-
case 'darwin':
|
|
111
|
-
localFileExisted = existsSync(join(__dirname, 'nacos-sdk-rust-binding-node.darwin-universal.node'))
|
|
112
|
-
try {
|
|
113
|
-
if (localFileExisted) {
|
|
114
|
-
nativeBinding = require('./nacos-sdk-rust-binding-node.darwin-universal.node')
|
|
115
315
|
} else {
|
|
116
|
-
nativeBinding = require('nacos-sdk-rust-binding-node-darwin-universal')
|
|
117
|
-
}
|
|
118
|
-
break
|
|
119
|
-
} catch {}
|
|
120
|
-
switch (arch) {
|
|
121
|
-
case 'x64':
|
|
122
|
-
localFileExisted = existsSync(join(__dirname, 'nacos-sdk-rust-binding-node.darwin-x64.node'))
|
|
123
316
|
try {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
317
|
+
return require('./nacos-sdk-rust-binding-node.linux-arm64-gnu.node')
|
|
318
|
+
} catch (e) {
|
|
319
|
+
loadErrors.push(e)
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
const binding = require('nacos-sdk-rust-binding-node-linux-arm64-gnu')
|
|
323
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-linux-arm64-gnu/package.json').version
|
|
324
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
128
326
|
}
|
|
327
|
+
return binding
|
|
328
|
+
} catch (e) {
|
|
329
|
+
loadErrors.push(e)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
} else if (process.arch === 'arm') {
|
|
333
|
+
if (isMusl()) {
|
|
334
|
+
try {
|
|
335
|
+
return require('./nacos-sdk-rust-binding-node.linux-arm-musleabihf.node')
|
|
129
336
|
} catch (e) {
|
|
130
|
-
|
|
337
|
+
loadErrors.push(e)
|
|
131
338
|
}
|
|
132
|
-
break
|
|
133
|
-
case 'arm64':
|
|
134
|
-
localFileExisted = existsSync(
|
|
135
|
-
join(__dirname, 'nacos-sdk-rust-binding-node.darwin-arm64.node')
|
|
136
|
-
)
|
|
137
339
|
try {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
340
|
+
const binding = require('nacos-sdk-rust-binding-node-linux-arm-musleabihf')
|
|
341
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-linux-arm-musleabihf/package.json').version
|
|
342
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
142
344
|
}
|
|
345
|
+
return binding
|
|
143
346
|
} catch (e) {
|
|
144
|
-
|
|
347
|
+
loadErrors.push(e)
|
|
145
348
|
}
|
|
146
|
-
break
|
|
147
|
-
default:
|
|
148
|
-
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
149
|
-
}
|
|
150
|
-
break
|
|
151
|
-
case 'freebsd':
|
|
152
|
-
if (arch !== 'x64') {
|
|
153
|
-
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
154
|
-
}
|
|
155
|
-
localFileExisted = existsSync(join(__dirname, 'nacos-sdk-rust-binding-node.freebsd-x64.node'))
|
|
156
|
-
try {
|
|
157
|
-
if (localFileExisted) {
|
|
158
|
-
nativeBinding = require('./nacos-sdk-rust-binding-node.freebsd-x64.node')
|
|
159
349
|
} else {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
localFileExisted = existsSync(
|
|
171
|
-
join(__dirname, 'nacos-sdk-rust-binding-node.linux-x64-musl.node')
|
|
172
|
-
)
|
|
173
|
-
try {
|
|
174
|
-
if (localFileExisted) {
|
|
175
|
-
nativeBinding = require('./nacos-sdk-rust-binding-node.linux-x64-musl.node')
|
|
176
|
-
} else {
|
|
177
|
-
nativeBinding = require('nacos-sdk-rust-binding-node-linux-x64-musl')
|
|
178
|
-
}
|
|
179
|
-
} catch (e) {
|
|
180
|
-
loadError = e
|
|
350
|
+
try {
|
|
351
|
+
return require('./nacos-sdk-rust-binding-node.linux-arm-gnueabihf.node')
|
|
352
|
+
} catch (e) {
|
|
353
|
+
loadErrors.push(e)
|
|
354
|
+
}
|
|
355
|
+
try {
|
|
356
|
+
const binding = require('nacos-sdk-rust-binding-node-linux-arm-gnueabihf')
|
|
357
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-linux-arm-gnueabihf/package.json').version
|
|
358
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
181
360
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
361
|
+
return binding
|
|
362
|
+
} catch (e) {
|
|
363
|
+
loadErrors.push(e)
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
} else if (process.arch === 'loong64') {
|
|
367
|
+
if (isMusl()) {
|
|
368
|
+
try {
|
|
369
|
+
return require('./nacos-sdk-rust-binding-node.linux-loong64-musl.node')
|
|
370
|
+
} catch (e) {
|
|
371
|
+
loadErrors.push(e)
|
|
372
|
+
}
|
|
373
|
+
try {
|
|
374
|
+
const binding = require('nacos-sdk-rust-binding-node-linux-loong64-musl')
|
|
375
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-linux-loong64-musl/package.json').version
|
|
376
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
194
378
|
}
|
|
379
|
+
return binding
|
|
380
|
+
} catch (e) {
|
|
381
|
+
loadErrors.push(e)
|
|
195
382
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
} catch (e) {
|
|
209
|
-
loadError = e
|
|
383
|
+
} else {
|
|
384
|
+
try {
|
|
385
|
+
return require('./nacos-sdk-rust-binding-node.linux-loong64-gnu.node')
|
|
386
|
+
} catch (e) {
|
|
387
|
+
loadErrors.push(e)
|
|
388
|
+
}
|
|
389
|
+
try {
|
|
390
|
+
const binding = require('nacos-sdk-rust-binding-node-linux-loong64-gnu')
|
|
391
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-linux-loong64-gnu/package.json').version
|
|
392
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
210
394
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
395
|
+
return binding
|
|
396
|
+
} catch (e) {
|
|
397
|
+
loadErrors.push(e)
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
} else if (process.arch === 'riscv64') {
|
|
401
|
+
if (isMusl()) {
|
|
402
|
+
try {
|
|
403
|
+
return require('./nacos-sdk-rust-binding-node.linux-riscv64-musl.node')
|
|
404
|
+
} catch (e) {
|
|
405
|
+
loadErrors.push(e)
|
|
406
|
+
}
|
|
407
|
+
try {
|
|
408
|
+
const binding = require('nacos-sdk-rust-binding-node-linux-riscv64-musl')
|
|
409
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-linux-riscv64-musl/package.json').version
|
|
410
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
223
412
|
}
|
|
413
|
+
return binding
|
|
414
|
+
} catch (e) {
|
|
415
|
+
loadErrors.push(e)
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
try {
|
|
419
|
+
return require('./nacos-sdk-rust-binding-node.linux-riscv64-gnu.node')
|
|
420
|
+
} catch (e) {
|
|
421
|
+
loadErrors.push(e)
|
|
224
422
|
}
|
|
225
|
-
break
|
|
226
|
-
case 'arm':
|
|
227
|
-
localFileExisted = existsSync(
|
|
228
|
-
join(__dirname, 'nacos-sdk-rust-binding-node.linux-arm-gnueabihf.node')
|
|
229
|
-
)
|
|
230
423
|
try {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
424
|
+
const binding = require('nacos-sdk-rust-binding-node-linux-riscv64-gnu')
|
|
425
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-linux-riscv64-gnu/package.json').version
|
|
426
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
235
428
|
}
|
|
429
|
+
return binding
|
|
236
430
|
} catch (e) {
|
|
237
|
-
|
|
431
|
+
loadErrors.push(e)
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
} else if (process.arch === 'ppc64') {
|
|
435
|
+
try {
|
|
436
|
+
return require('./nacos-sdk-rust-binding-node.linux-ppc64-gnu.node')
|
|
437
|
+
} catch (e) {
|
|
438
|
+
loadErrors.push(e)
|
|
439
|
+
}
|
|
440
|
+
try {
|
|
441
|
+
const binding = require('nacos-sdk-rust-binding-node-linux-ppc64-gnu')
|
|
442
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-linux-ppc64-gnu/package.json').version
|
|
443
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
|
+
}
|
|
446
|
+
return binding
|
|
447
|
+
} catch (e) {
|
|
448
|
+
loadErrors.push(e)
|
|
449
|
+
}
|
|
450
|
+
} else if (process.arch === 's390x') {
|
|
451
|
+
try {
|
|
452
|
+
return require('./nacos-sdk-rust-binding-node.linux-s390x-gnu.node')
|
|
453
|
+
} catch (e) {
|
|
454
|
+
loadErrors.push(e)
|
|
455
|
+
}
|
|
456
|
+
try {
|
|
457
|
+
const binding = require('nacos-sdk-rust-binding-node-linux-s390x-gnu')
|
|
458
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-linux-s390x-gnu/package.json').version
|
|
459
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
|
+
}
|
|
462
|
+
return binding
|
|
463
|
+
} catch (e) {
|
|
464
|
+
loadErrors.push(e)
|
|
465
|
+
}
|
|
466
|
+
} else {
|
|
467
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
468
|
+
}
|
|
469
|
+
} else if (process.platform === 'openharmony') {
|
|
470
|
+
if (process.arch === 'arm64') {
|
|
471
|
+
try {
|
|
472
|
+
return require('./nacos-sdk-rust-binding-node.openharmony-arm64.node')
|
|
473
|
+
} catch (e) {
|
|
474
|
+
loadErrors.push(e)
|
|
475
|
+
}
|
|
476
|
+
try {
|
|
477
|
+
const binding = require('nacos-sdk-rust-binding-node-openharmony-arm64')
|
|
478
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-openharmony-arm64/package.json').version
|
|
479
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
|
+
}
|
|
482
|
+
return binding
|
|
483
|
+
} catch (e) {
|
|
484
|
+
loadErrors.push(e)
|
|
485
|
+
}
|
|
486
|
+
} else if (process.arch === 'x64') {
|
|
487
|
+
try {
|
|
488
|
+
return require('./nacos-sdk-rust-binding-node.openharmony-x64.node')
|
|
489
|
+
} catch (e) {
|
|
490
|
+
loadErrors.push(e)
|
|
491
|
+
}
|
|
492
|
+
try {
|
|
493
|
+
const binding = require('nacos-sdk-rust-binding-node-openharmony-x64')
|
|
494
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-openharmony-x64/package.json').version
|
|
495
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
238
497
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
498
|
+
return binding
|
|
499
|
+
} catch (e) {
|
|
500
|
+
loadErrors.push(e)
|
|
501
|
+
}
|
|
502
|
+
} else if (process.arch === 'arm') {
|
|
503
|
+
try {
|
|
504
|
+
return require('./nacos-sdk-rust-binding-node.openharmony-arm.node')
|
|
505
|
+
} catch (e) {
|
|
506
|
+
loadErrors.push(e)
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
const binding = require('nacos-sdk-rust-binding-node-openharmony-arm')
|
|
510
|
+
const bindingPackageVersion = require('nacos-sdk-rust-binding-node-openharmony-arm/package.json').version
|
|
511
|
+
if (bindingPackageVersion !== '0.5.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 0.5.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
|
+
}
|
|
514
|
+
return binding
|
|
515
|
+
} catch (e) {
|
|
516
|
+
loadErrors.push(e)
|
|
517
|
+
}
|
|
518
|
+
} else {
|
|
519
|
+
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
242
520
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
521
|
+
} else {
|
|
522
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
nativeBinding = requireNative()
|
|
527
|
+
|
|
528
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
529
|
+
let wasiBinding = null
|
|
530
|
+
let wasiBindingError = null
|
|
531
|
+
try {
|
|
532
|
+
wasiBinding = require('./nacos-sdk-rust-binding-node.wasi.cjs')
|
|
533
|
+
nativeBinding = wasiBinding
|
|
534
|
+
} catch (err) {
|
|
535
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
536
|
+
wasiBindingError = err
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
540
|
+
try {
|
|
541
|
+
wasiBinding = require('nacos-sdk-rust-binding-node-wasm32-wasi')
|
|
542
|
+
nativeBinding = wasiBinding
|
|
543
|
+
} catch (err) {
|
|
544
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
545
|
+
if (!wasiBindingError) {
|
|
546
|
+
wasiBindingError = err
|
|
547
|
+
} else {
|
|
548
|
+
wasiBindingError.cause = err
|
|
549
|
+
}
|
|
550
|
+
loadErrors.push(err)
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
555
|
+
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
|
556
|
+
error.cause = wasiBindingError
|
|
557
|
+
throw error
|
|
558
|
+
}
|
|
246
559
|
}
|
|
247
560
|
|
|
248
561
|
if (!nativeBinding) {
|
|
249
|
-
if (
|
|
250
|
-
throw
|
|
562
|
+
if (loadErrors.length > 0) {
|
|
563
|
+
throw new Error(
|
|
564
|
+
`Cannot find native binding. ` +
|
|
565
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
566
|
+
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
567
|
+
{
|
|
568
|
+
cause: loadErrors.reduce((err, cur) => {
|
|
569
|
+
cur.cause = err
|
|
570
|
+
return cur
|
|
571
|
+
}),
|
|
572
|
+
},
|
|
573
|
+
)
|
|
251
574
|
}
|
|
252
575
|
throw new Error(`Failed to load native binding`)
|
|
253
576
|
}
|
|
254
577
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
module.exports.
|
|
258
|
-
module.exports.
|
|
259
|
-
module.exports.NacosNamingClient = NacosNamingClient
|
|
578
|
+
module.exports = nativeBinding
|
|
579
|
+
module.exports.NacosConfigClient = nativeBinding.NacosConfigClient
|
|
580
|
+
module.exports.NacosNamingClient = nativeBinding.NacosNamingClient
|
|
581
|
+
module.exports.sum = nativeBinding.sum
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"binding",
|
|
8
8
|
"ffi"
|
|
9
9
|
],
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.5.3-BETA2",
|
|
11
11
|
"bugs": "https://github.com/opc-source/nacos-sdk-rust-binding-node/issues",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"repository": {
|
|
@@ -55,19 +55,16 @@
|
|
|
55
55
|
},
|
|
56
56
|
"packageManager": "yarn@3.4.1",
|
|
57
57
|
"optionalDependencies": {
|
|
58
|
-
"nacos-sdk-rust-binding-node-
|
|
59
|
-
"nacos-sdk-rust-binding-node-
|
|
60
|
-
"nacos-sdk-rust-binding-node-linux-
|
|
61
|
-
"nacos-sdk-rust-binding-node-
|
|
62
|
-
"nacos-sdk-rust-binding-node-
|
|
63
|
-
"nacos-sdk-rust-binding-node-linux-
|
|
64
|
-
"nacos-sdk-rust-binding-node-linux-
|
|
65
|
-
"nacos-sdk-rust-binding-node-
|
|
66
|
-
"nacos-sdk-rust-binding-node-
|
|
67
|
-
"nacos-sdk-rust-binding-node-
|
|
68
|
-
"nacos-sdk-rust-binding-node-
|
|
69
|
-
"nacos-sdk-rust-binding-node-win32-ia32-msvc": "0.4.2",
|
|
70
|
-
"nacos-sdk-rust-binding-node-android-arm-eabi": "0.4.2",
|
|
71
|
-
"nacos-sdk-rust-binding-node-darwin-universal": "0.4.2"
|
|
58
|
+
"nacos-sdk-rust-binding-node-darwin-arm64": "0.5.3-BETA2",
|
|
59
|
+
"nacos-sdk-rust-binding-node-android-arm64": "0.5.3-BETA2",
|
|
60
|
+
"nacos-sdk-rust-binding-node-linux-arm64-gnu": "0.5.3-BETA2",
|
|
61
|
+
"nacos-sdk-rust-binding-node-linux-arm64-musl": "0.5.3-BETA2",
|
|
62
|
+
"nacos-sdk-rust-binding-node-win32-arm64-msvc": "0.5.3-BETA2",
|
|
63
|
+
"nacos-sdk-rust-binding-node-linux-arm-gnueabihf": "0.5.3-BETA2",
|
|
64
|
+
"nacos-sdk-rust-binding-node-linux-x64-musl": "0.5.3-BETA2",
|
|
65
|
+
"nacos-sdk-rust-binding-node-freebsd-x64": "0.5.3-BETA2",
|
|
66
|
+
"nacos-sdk-rust-binding-node-win32-ia32-msvc": "0.5.3-BETA2",
|
|
67
|
+
"nacos-sdk-rust-binding-node-android-arm-eabi": "0.5.3-BETA2",
|
|
68
|
+
"nacos-sdk-rust-binding-node-darwin-universal": "0.5.3-BETA2"
|
|
72
69
|
}
|
|
73
70
|
}
|
package/src/config.rs
CHANGED
|
@@ -6,7 +6,7 @@ use std::sync::Arc;
|
|
|
6
6
|
/// Client api of Nacos Config.
|
|
7
7
|
#[napi]
|
|
8
8
|
pub struct NacosConfigClient {
|
|
9
|
-
inner:
|
|
9
|
+
inner: nacos_sdk::api::config::ConfigService,
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
#[napi]
|
|
@@ -22,9 +22,6 @@ impl NacosConfigClient {
|
|
|
22
22
|
)>,
|
|
23
23
|
>,
|
|
24
24
|
) -> Result<NacosConfigClient> {
|
|
25
|
-
// print to console or file
|
|
26
|
-
let _ = crate::init_logger();
|
|
27
|
-
|
|
28
25
|
let props = nacos_sdk::api::props::ClientProps::new()
|
|
29
26
|
.server_addr(client_options.server_addr)
|
|
30
27
|
.namespace(client_options.namespace)
|
|
@@ -75,7 +72,7 @@ impl NacosConfigClient {
|
|
|
75
72
|
.map_err(|nacos_err| Error::from_reason(nacos_err.to_string()))?;
|
|
76
73
|
|
|
77
74
|
Ok(NacosConfigClient {
|
|
78
|
-
inner:
|
|
75
|
+
inner: config_service,
|
|
79
76
|
})
|
|
80
77
|
}
|
|
81
78
|
|
package/src/lib.rs
CHANGED
|
@@ -8,40 +8,6 @@ pub fn sum(a: i32, b: i32) -> i32 {
|
|
|
8
8
|
a + b
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
lazy_static::lazy_static! {
|
|
12
|
-
static ref LOG_GUARD: tracing_appender::non_blocking::WorkerGuard = {
|
|
13
|
-
use std::str::FromStr;
|
|
14
|
-
use tracing_subscriber::filter::LevelFilter;
|
|
15
|
-
let log_level = match std::env::var("NACOS_CLIENT_LOGGER_LEVEL") {
|
|
16
|
-
Ok(level) => LevelFilter::from_str(&level).unwrap_or(LevelFilter::INFO),
|
|
17
|
-
Err(_) => LevelFilter::INFO,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
let home_dir = match std::env::var("HOME") {
|
|
21
|
-
Ok(dir) => dir,
|
|
22
|
-
Err(_) => "/tmp".to_string(),
|
|
23
|
-
};
|
|
24
|
-
let file_appender = tracing_appender::rolling::daily(home_dir + "/logs/nacos", "nacos.log");
|
|
25
|
-
let (non_blocking, guard) = tracing_appender::non_blocking(file_appender);
|
|
26
|
-
|
|
27
|
-
tracing_subscriber::fmt()
|
|
28
|
-
.with_writer(non_blocking)
|
|
29
|
-
// .with_timer(tracing_subscriber::fmt::time::LocalTime::rfc_3339()) // occur `<unknown time>`
|
|
30
|
-
.with_thread_names(true)
|
|
31
|
-
.with_thread_ids(true)
|
|
32
|
-
.with_max_level(log_level)
|
|
33
|
-
.init();
|
|
34
|
-
|
|
35
|
-
guard
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/// log print to console or file
|
|
41
|
-
fn init_logger() -> &'static tracing_appender::non_blocking::WorkerGuard {
|
|
42
|
-
&LOG_GUARD
|
|
43
|
-
}
|
|
44
|
-
|
|
45
11
|
#[napi(object)]
|
|
46
12
|
pub struct ClientOptions {
|
|
47
13
|
/// Server Addr, e.g. address:port[,address:port],...]
|
package/src/naming.rs
CHANGED
|
@@ -6,7 +6,7 @@ use std::sync::Arc;
|
|
|
6
6
|
/// Client api of Nacos Naming.
|
|
7
7
|
#[napi]
|
|
8
8
|
pub struct NacosNamingClient {
|
|
9
|
-
inner:
|
|
9
|
+
inner: nacos_sdk::api::naming::NamingService,
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
#[napi]
|
|
@@ -14,9 +14,6 @@ impl NacosNamingClient {
|
|
|
14
14
|
/// Build a Naming Client.
|
|
15
15
|
#[napi(constructor)]
|
|
16
16
|
pub fn new(client_options: crate::ClientOptions) -> Result<NacosNamingClient> {
|
|
17
|
-
// print to console or file
|
|
18
|
-
let _ = crate::init_logger();
|
|
19
|
-
|
|
20
17
|
let props = nacos_sdk::api::props::ClientProps::new()
|
|
21
18
|
.server_addr(client_options.server_addr)
|
|
22
19
|
.namespace(client_options.namespace)
|
|
@@ -61,7 +58,7 @@ impl NacosNamingClient {
|
|
|
61
58
|
.map_err(|nacos_err| Error::from_reason(nacos_err.to_string()))?;
|
|
62
59
|
|
|
63
60
|
Ok(NacosNamingClient {
|
|
64
|
-
inner:
|
|
61
|
+
inner: naming_service,
|
|
65
62
|
})
|
|
66
63
|
}
|
|
67
64
|
|