nacos-sdk-rust-binding-node 0.4.0 → 0.4.2
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/index.d.ts +9 -3
- package/package.json +15 -15
- package/src/config.rs +14 -3
- package/src/lib.rs +8 -2
- package/src/naming.rs +14 -3
package/Cargo.toml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
edition = "2021"
|
|
3
3
|
name = "nacos-sdk-rust-binding-node"
|
|
4
|
-
version = "0.4.
|
|
4
|
+
version = "0.4.2"
|
|
5
5
|
authors = ["CheirshCai <785427346@qq.com>"]
|
|
6
6
|
license = "Apache-2.0"
|
|
7
7
|
readme = "README.md"
|
|
@@ -18,7 +18,7 @@ crate-type = ["cdylib"]
|
|
|
18
18
|
napi = { version = "2", default-features = false, features = ["napi4", "async"] }
|
|
19
19
|
napi-derive = "2"
|
|
20
20
|
|
|
21
|
-
nacos-sdk = { version = "0.4.
|
|
21
|
+
nacos-sdk = { version = "0.4.2", features = ["default", "auth-by-aliyun"] }
|
|
22
22
|
#nacos-sdk = { git = "https://github.com/nacos-group/nacos-sdk-rust.git", branch = "main", features = ["default"] }
|
|
23
23
|
|
|
24
24
|
tracing-subscriber = { version = "0.3", features = ["default"] }
|
package/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
-
export function sum(a: number, b: number): number
|
|
6
|
+
export declare function sum(a: number, b: number): number
|
|
7
7
|
export interface ClientOptions {
|
|
8
8
|
/** Server Addr, e.g. address:port[,address:port],...] */
|
|
9
9
|
serverAddr: string
|
|
@@ -11,10 +11,16 @@ export interface ClientOptions {
|
|
|
11
11
|
namespace: string
|
|
12
12
|
/** AppName */
|
|
13
13
|
appName?: string
|
|
14
|
-
/** Username for Auth */
|
|
14
|
+
/** Username for Auth, Login by Http with Token */
|
|
15
15
|
username?: string
|
|
16
|
-
/** Password for Auth */
|
|
16
|
+
/** Password for Auth, Login by Http with Token */
|
|
17
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
|
|
18
24
|
/** naming push_empty_protection, default true */
|
|
19
25
|
namingPushEmptyProtection?: boolean
|
|
20
26
|
/** naming load_cache_at_start, default false */
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"binding",
|
|
8
8
|
"ffi"
|
|
9
9
|
],
|
|
10
|
-
"version": "0.4.
|
|
10
|
+
"version": "0.4.2",
|
|
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.4.
|
|
59
|
-
"nacos-sdk-rust-binding-node-darwin-x64": "0.4.
|
|
60
|
-
"nacos-sdk-rust-binding-node-linux-x64-gnu": "0.4.
|
|
61
|
-
"nacos-sdk-rust-binding-node-darwin-arm64": "0.4.
|
|
62
|
-
"nacos-sdk-rust-binding-node-android-arm64": "0.4.
|
|
63
|
-
"nacos-sdk-rust-binding-node-linux-arm64-gnu": "0.4.
|
|
64
|
-
"nacos-sdk-rust-binding-node-linux-arm64-musl": "0.4.
|
|
65
|
-
"nacos-sdk-rust-binding-node-win32-arm64-msvc": "0.4.
|
|
66
|
-
"nacos-sdk-rust-binding-node-linux-arm-gnueabihf": "0.4.
|
|
67
|
-
"nacos-sdk-rust-binding-node-linux-x64-musl": "0.4.
|
|
68
|
-
"nacos-sdk-rust-binding-node-freebsd-x64": "0.4.
|
|
69
|
-
"nacos-sdk-rust-binding-node-win32-ia32-msvc": "0.4.
|
|
70
|
-
"nacos-sdk-rust-binding-node-android-arm-eabi": "0.4.
|
|
71
|
-
"nacos-sdk-rust-binding-node-darwin-universal": "0.4.
|
|
58
|
+
"nacos-sdk-rust-binding-node-win32-x64-msvc": "0.4.2",
|
|
59
|
+
"nacos-sdk-rust-binding-node-darwin-x64": "0.4.2",
|
|
60
|
+
"nacos-sdk-rust-binding-node-linux-x64-gnu": "0.4.2",
|
|
61
|
+
"nacos-sdk-rust-binding-node-darwin-arm64": "0.4.2",
|
|
62
|
+
"nacos-sdk-rust-binding-node-android-arm64": "0.4.2",
|
|
63
|
+
"nacos-sdk-rust-binding-node-linux-arm64-gnu": "0.4.2",
|
|
64
|
+
"nacos-sdk-rust-binding-node-linux-arm64-musl": "0.4.2",
|
|
65
|
+
"nacos-sdk-rust-binding-node-win32-arm64-msvc": "0.4.2",
|
|
66
|
+
"nacos-sdk-rust-binding-node-linux-arm-gnueabihf": "0.4.2",
|
|
67
|
+
"nacos-sdk-rust-binding-node-linux-x64-musl": "0.4.2",
|
|
68
|
+
"nacos-sdk-rust-binding-node-freebsd-x64": "0.4.2",
|
|
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"
|
|
72
72
|
}
|
|
73
73
|
}
|
package/src/config.rs
CHANGED
|
@@ -35,18 +35,29 @@ impl NacosConfigClient {
|
|
|
35
35
|
);
|
|
36
36
|
|
|
37
37
|
// need enable_auth_plugin_http with username & password
|
|
38
|
-
let
|
|
38
|
+
let is_enable_auth_http =
|
|
39
|
+
client_options.username.is_some() && client_options.password.is_some();
|
|
40
|
+
// need enable_auth_plugin_aliyun with access_key & access_secret
|
|
41
|
+
let is_enable_auth_aliyun =
|
|
42
|
+
client_options.access_key.is_some() && client_options.access_secret.is_some();
|
|
39
43
|
|
|
40
|
-
let props = if
|
|
44
|
+
let props = if is_enable_auth_http {
|
|
41
45
|
props
|
|
42
46
|
.auth_username(client_options.username.unwrap())
|
|
43
47
|
.auth_password(client_options.password.unwrap())
|
|
48
|
+
} else if is_enable_auth_aliyun {
|
|
49
|
+
props
|
|
50
|
+
.auth_access_key(client_options.access_key.unwrap())
|
|
51
|
+
.auth_access_secret(client_options.access_secret.unwrap())
|
|
52
|
+
.auth_signature_region_id(client_options.signature_region_id.unwrap())
|
|
44
53
|
} else {
|
|
45
54
|
props
|
|
46
55
|
};
|
|
47
56
|
|
|
48
|
-
let config_service_builder = if
|
|
57
|
+
let config_service_builder = if is_enable_auth_http {
|
|
49
58
|
nacos_sdk::api::config::ConfigServiceBuilder::new(props).enable_auth_plugin_http()
|
|
59
|
+
} else if is_enable_auth_aliyun {
|
|
60
|
+
nacos_sdk::api::config::ConfigServiceBuilder::new(props).enable_auth_plugin_aliyun()
|
|
50
61
|
} else {
|
|
51
62
|
nacos_sdk::api::config::ConfigServiceBuilder::new(props)
|
|
52
63
|
};
|
package/src/lib.rs
CHANGED
|
@@ -50,10 +50,16 @@ pub struct ClientOptions {
|
|
|
50
50
|
pub namespace: String,
|
|
51
51
|
/// AppName
|
|
52
52
|
pub app_name: Option<String>,
|
|
53
|
-
/// Username for Auth
|
|
53
|
+
/// Username for Auth, Login by Http with Token
|
|
54
54
|
pub username: Option<String>,
|
|
55
|
-
/// Password for Auth
|
|
55
|
+
/// Password for Auth, Login by Http with Token
|
|
56
56
|
pub password: Option<String>,
|
|
57
|
+
/// Access_Key for Auth, Login by Aliyun Ram
|
|
58
|
+
pub access_key: Option<String>,
|
|
59
|
+
/// Access_Secret for Auth, Login by Aliyun Ram
|
|
60
|
+
pub access_secret: Option<String>,
|
|
61
|
+
/// Signature_Region_Id for Auth, Login by Aliyun Ram
|
|
62
|
+
pub signature_region_id: Option<String>,
|
|
57
63
|
/// naming push_empty_protection, default true
|
|
58
64
|
pub naming_push_empty_protection: Option<bool>,
|
|
59
65
|
/// naming load_cache_at_start, default false
|
package/src/naming.rs
CHANGED
|
@@ -29,18 +29,29 @@ impl NacosNamingClient {
|
|
|
29
29
|
.naming_load_cache_at_start(client_options.naming_load_cache_at_start.unwrap_or(false));
|
|
30
30
|
|
|
31
31
|
// need enable_auth_plugin_http with username & password
|
|
32
|
-
let
|
|
32
|
+
let is_enable_auth_http =
|
|
33
|
+
client_options.username.is_some() && client_options.password.is_some();
|
|
34
|
+
// need enable_auth_plugin_aliyun with access_key & access_secret
|
|
35
|
+
let is_enable_auth_aliyun =
|
|
36
|
+
client_options.access_key.is_some() && client_options.access_secret.is_some();
|
|
33
37
|
|
|
34
|
-
let props = if
|
|
38
|
+
let props = if is_enable_auth_http {
|
|
35
39
|
props
|
|
36
40
|
.auth_username(client_options.username.unwrap())
|
|
37
41
|
.auth_password(client_options.password.unwrap())
|
|
42
|
+
} else if is_enable_auth_aliyun {
|
|
43
|
+
props
|
|
44
|
+
.auth_access_key(client_options.access_key.unwrap())
|
|
45
|
+
.auth_access_secret(client_options.access_secret.unwrap())
|
|
46
|
+
.auth_signature_region_id(client_options.signature_region_id.unwrap())
|
|
38
47
|
} else {
|
|
39
48
|
props
|
|
40
49
|
};
|
|
41
50
|
|
|
42
|
-
let naming_service_builder = if
|
|
51
|
+
let naming_service_builder = if is_enable_auth_http {
|
|
43
52
|
nacos_sdk::api::naming::NamingServiceBuilder::new(props).enable_auth_plugin_http()
|
|
53
|
+
} else if is_enable_auth_aliyun {
|
|
54
|
+
nacos_sdk::api::naming::NamingServiceBuilder::new(props).enable_auth_plugin_aliyun()
|
|
44
55
|
} else {
|
|
45
56
|
nacos_sdk::api::naming::NamingServiceBuilder::new(props)
|
|
46
57
|
};
|