nacos-sdk-rust-binding-node 0.6.0 → 0.7.0
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/Cargo.toml +2 -2
- package/example/config.js +20 -8
- package/example/config_decrypt.js +21 -9
- package/package.json +15 -15
- package/src/lib.rs +10 -10
- package/tea.yaml +0 -7
package/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "nacos-sdk-rust-binding-node"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.7.0"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
publish = false
|
|
@@ -19,7 +19,7 @@ crate-type = ["cdylib"]
|
|
|
19
19
|
napi = { version = "2", default-features = false, features = ["napi4", "async"] }
|
|
20
20
|
napi-derive = "2"
|
|
21
21
|
|
|
22
|
-
nacos-sdk = { version = "0.
|
|
22
|
+
nacos-sdk = { version = "0.7.0", features = ["default", "auth-by-aliyun", "tracing-log"] }
|
|
23
23
|
#nacos-sdk = { git = "https://github.com/nacos-group/nacos-sdk-rust.git", branch = "main", features = ["default", "auth-by-aliyun", "tracing-log"] }
|
|
24
24
|
|
|
25
25
|
async-trait = "0.1"
|
package/example/config.js
CHANGED
|
@@ -11,17 +11,29 @@ const nacos_config_client = new NacosConfigClient({
|
|
|
11
11
|
appName: "binding-node-example-app"
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
// getConfig - config may not exist, handle error gracefully
|
|
15
|
+
nacos_config_client.getConfig('todo-dataid', 'LOVE')
|
|
16
|
+
.then(data => {
|
|
17
17
|
console.log('getConfig => ' + data);
|
|
18
|
+
})
|
|
19
|
+
.catch(err => {
|
|
20
|
+
console.log('getConfig error: ' + err.message);
|
|
18
21
|
});
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
// getConfigResp - config may not exist, handle error gracefully
|
|
24
|
+
nacos_config_client.getConfigResp('todo-dataid', 'LOVE')
|
|
25
|
+
.then(data => {
|
|
21
26
|
console.log('getConfigResp => ' + JSON.stringify(data));
|
|
27
|
+
})
|
|
28
|
+
.catch(err => {
|
|
29
|
+
console.log('getConfigResp error: ' + err.message);
|
|
22
30
|
});
|
|
23
|
-
} catch(e) {
|
|
24
|
-
console.log(e);
|
|
25
|
-
}
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
// addListener - listener will be called when config is created/changed
|
|
33
|
+
nacos_config_client.addListener('todo-dataid', 'LOVE', (err, config_resp) => {
|
|
34
|
+
if (err) {
|
|
35
|
+
console.log('addListener error: ' + err.message);
|
|
36
|
+
} else {
|
|
37
|
+
console.log('config changed => ' + JSON.stringify(config_resp));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
@@ -27,17 +27,29 @@ const nacos_config_client = new NacosConfigClient(
|
|
|
27
27
|
}
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
// getConfig - config may not exist, handle error gracefully
|
|
31
|
+
nacos_config_client.getConfig('todo-dataid', 'LOVE')
|
|
32
|
+
.then(data => {
|
|
33
33
|
console.log('getConfig => ' + data);
|
|
34
|
+
})
|
|
35
|
+
.catch(err => {
|
|
36
|
+
console.log('getConfig error (config may not exist): ' + err.message);
|
|
34
37
|
});
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
|
|
39
|
+
// getConfigResp - config may not exist, handle error gracefully
|
|
40
|
+
nacos_config_client.getConfigResp('todo-dataid', 'LOVE')
|
|
41
|
+
.then(data => {
|
|
37
42
|
console.log('getConfigResp => ' + JSON.stringify(data));
|
|
43
|
+
})
|
|
44
|
+
.catch(err => {
|
|
45
|
+
console.log('getConfigResp error (config may not exist): ' + err.message);
|
|
38
46
|
});
|
|
39
|
-
} catch(e) {
|
|
40
|
-
console.log(e);
|
|
41
|
-
}
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
// addListener - listener will be called when config is created/changed
|
|
49
|
+
nacos_config_client.addListener('todo-dataid', 'LOVE', (err, config_resp) => {
|
|
50
|
+
if (err) {
|
|
51
|
+
console.log('addListener error: ' + err.message);
|
|
52
|
+
} else {
|
|
53
|
+
console.log('config changed => ' + JSON.stringify(config_resp));
|
|
54
|
+
}
|
|
55
|
+
});
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"binding",
|
|
8
8
|
"ffi"
|
|
9
9
|
],
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.7.0",
|
|
11
11
|
"bugs": "https://github.com/opc-source/nacos-sdk-rust-binding-node/issues",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"repository": {
|
|
@@ -55,19 +55,19 @@
|
|
|
55
55
|
},
|
|
56
56
|
"packageManager": "yarn@3.4.1",
|
|
57
57
|
"optionalDependencies": {
|
|
58
|
-
"nacos-sdk-rust-binding-node-win32-x64-msvc": "0.
|
|
59
|
-
"nacos-sdk-rust-binding-node-darwin-x64": "0.
|
|
60
|
-
"nacos-sdk-rust-binding-node-linux-x64-gnu": "0.
|
|
61
|
-
"nacos-sdk-rust-binding-node-darwin-arm64": "0.
|
|
62
|
-
"nacos-sdk-rust-binding-node-android-arm64": "0.
|
|
63
|
-
"nacos-sdk-rust-binding-node-linux-arm64-gnu": "0.
|
|
64
|
-
"nacos-sdk-rust-binding-node-linux-arm64-musl": "0.
|
|
65
|
-
"nacos-sdk-rust-binding-node-win32-arm64-msvc": "0.
|
|
66
|
-
"nacos-sdk-rust-binding-node-linux-arm-gnueabihf": "0.
|
|
67
|
-
"nacos-sdk-rust-binding-node-linux-x64-musl": "0.
|
|
68
|
-
"nacos-sdk-rust-binding-node-freebsd-x64": "0.
|
|
69
|
-
"nacos-sdk-rust-binding-node-win32-ia32-msvc": "0.
|
|
70
|
-
"nacos-sdk-rust-binding-node-android-arm-eabi": "0.
|
|
71
|
-
"nacos-sdk-rust-binding-node-darwin-universal": "0.
|
|
58
|
+
"nacos-sdk-rust-binding-node-win32-x64-msvc": "0.7.0",
|
|
59
|
+
"nacos-sdk-rust-binding-node-darwin-x64": "0.7.0",
|
|
60
|
+
"nacos-sdk-rust-binding-node-linux-x64-gnu": "0.7.0",
|
|
61
|
+
"nacos-sdk-rust-binding-node-darwin-arm64": "0.7.0",
|
|
62
|
+
"nacos-sdk-rust-binding-node-android-arm64": "0.7.0",
|
|
63
|
+
"nacos-sdk-rust-binding-node-linux-arm64-gnu": "0.7.0",
|
|
64
|
+
"nacos-sdk-rust-binding-node-linux-arm64-musl": "0.7.0",
|
|
65
|
+
"nacos-sdk-rust-binding-node-win32-arm64-msvc": "0.7.0",
|
|
66
|
+
"nacos-sdk-rust-binding-node-linux-arm-gnueabihf": "0.7.0",
|
|
67
|
+
"nacos-sdk-rust-binding-node-linux-x64-musl": "0.7.0",
|
|
68
|
+
"nacos-sdk-rust-binding-node-freebsd-x64": "0.7.0",
|
|
69
|
+
"nacos-sdk-rust-binding-node-win32-ia32-msvc": "0.7.0",
|
|
70
|
+
"nacos-sdk-rust-binding-node-android-arm-eabi": "0.7.0",
|
|
71
|
+
"nacos-sdk-rust-binding-node-darwin-universal": "0.7.0"
|
|
72
72
|
}
|
|
73
73
|
}
|
package/src/lib.rs
CHANGED
|
@@ -8,16 +8,16 @@ pub fn sum(a: i32, b: i32) -> i32 {
|
|
|
8
8
|
a + b
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
static RT: std::sync::OnceLock<tokio::runtime::Runtime> = std::sync::OnceLock::new();
|
|
13
|
-
|
|
14
|
-
pub fn get_runtime() ->
|
|
15
|
-
RT.get_or_init(|| {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
11
|
+
// Global Tokio runtime for async operations in constructors
|
|
12
|
+
// static RT: std::sync::OnceLock<tokio::runtime::Runtime> = std::sync::OnceLock::new();
|
|
13
|
+
|
|
14
|
+
pub fn get_runtime() -> tokio::runtime::Runtime {
|
|
15
|
+
// RT.get_or_init(|| {
|
|
16
|
+
tokio::runtime::Builder::new_current_thread()
|
|
17
|
+
.enable_all()
|
|
18
|
+
.build()
|
|
19
|
+
.expect("Failed to create Tokio runtime")
|
|
20
|
+
// })
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
#[napi(object)]
|