nacos-sdk-rust-binding-node 0.7.0 → 0.8.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "nacos-sdk-rust-binding-node"
3
- version = "0.7.0"
3
+ version = "0.8.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.7.0", features = ["default", "auth-by-aliyun", "tracing-log"] }
22
+ nacos-sdk = { version = "0.8.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/index.d.ts CHANGED
@@ -5,8 +5,18 @@
5
5
 
6
6
  export declare function sum(a: number, b: number): number
7
7
  export interface ClientOptions {
8
- /** Server Addr, e.g. address:port[,address:port],...] */
8
+ /**
9
+ * Server Addr, e.g. address:port[,address:port],...
10
+ * Note: endpoint takes priority over server_addr when both are provided.
11
+ */
9
12
  serverAddr: string
13
+ /**
14
+ * Endpoint is used to resolve server addresses dynamically.
15
+ * - Full URL (e.g. http://addr:8080/nacos/serverlist): used as-is, appends namespace if missing in query string.
16
+ * - Bare hostname (e.g. addr or addr:9090): uses default path /nacos/serverlist and default port 8080.
17
+ * Note: endpoint takes priority over server_addr when both are provided.
18
+ */
19
+ endpoint?: string
10
20
  /** Namespace/Tenant */
11
21
  namespace: string
12
22
  /** AppName */
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "binding",
8
8
  "ffi"
9
9
  ],
10
- "version": "0.7.0",
10
+ "version": "0.8.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.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"
58
+ "nacos-sdk-rust-binding-node-win32-x64-msvc": "0.8.0",
59
+ "nacos-sdk-rust-binding-node-darwin-x64": "0.8.0",
60
+ "nacos-sdk-rust-binding-node-linux-x64-gnu": "0.8.0",
61
+ "nacos-sdk-rust-binding-node-darwin-arm64": "0.8.0",
62
+ "nacos-sdk-rust-binding-node-android-arm64": "0.8.0",
63
+ "nacos-sdk-rust-binding-node-linux-arm64-gnu": "0.8.0",
64
+ "nacos-sdk-rust-binding-node-linux-arm64-musl": "0.8.0",
65
+ "nacos-sdk-rust-binding-node-win32-arm64-msvc": "0.8.0",
66
+ "nacos-sdk-rust-binding-node-linux-arm-gnueabihf": "0.8.0",
67
+ "nacos-sdk-rust-binding-node-linux-x64-musl": "0.8.0",
68
+ "nacos-sdk-rust-binding-node-freebsd-x64": "0.8.0",
69
+ "nacos-sdk-rust-binding-node-win32-ia32-msvc": "0.8.0",
70
+ "nacos-sdk-rust-binding-node-android-arm-eabi": "0.8.0",
71
+ "nacos-sdk-rust-binding-node-darwin-universal": "0.8.0"
72
72
  }
73
73
  }
package/src/config.rs CHANGED
@@ -22,7 +22,7 @@ impl NacosConfigClient {
22
22
  )>,
23
23
  >,
24
24
  ) -> Result<NacosConfigClient> {
25
- let props = nacos_sdk::api::props::ClientProps::new()
25
+ let mut props = nacos_sdk::api::props::ClientProps::new()
26
26
  .server_addr(client_options.server_addr)
27
27
  .namespace(client_options.namespace)
28
28
  .app_name(
@@ -32,6 +32,11 @@ impl NacosConfigClient {
32
32
  )
33
33
  .config_load_cache_at_start(client_options.config_load_cache_at_start.unwrap_or(false));
34
34
 
35
+ // endpoint takes priority over server_addr when both are provided
36
+ if let Some(endpoint) = client_options.endpoint {
37
+ props = props.endpoint(endpoint);
38
+ }
39
+
35
40
  // need enable_auth_plugin_http with username & password
36
41
  let is_enable_auth_http =
37
42
  client_options.username.is_some() && client_options.password.is_some();
package/src/lib.rs CHANGED
@@ -22,8 +22,14 @@ pub fn get_runtime() -> tokio::runtime::Runtime {
22
22
 
23
23
  #[napi(object)]
24
24
  pub struct ClientOptions {
25
- /// Server Addr, e.g. address:port[,address:port],...]
25
+ /// Server Addr, e.g. address:port[,address:port],...
26
+ /// Note: endpoint takes priority over server_addr when both are provided.
26
27
  pub server_addr: String,
28
+ /// Endpoint is used to resolve server addresses dynamically.
29
+ /// - Full URL (e.g. http://addr:8080/nacos/serverlist): used as-is, appends namespace if missing in query string.
30
+ /// - Bare hostname (e.g. addr or addr:9090): uses default path /nacos/serverlist and default port 8080.
31
+ /// Note: endpoint takes priority over server_addr when both are provided.
32
+ pub endpoint: Option<String>,
27
33
  /// Namespace/Tenant
28
34
  pub namespace: String,
29
35
  /// AppName
package/src/naming.rs CHANGED
@@ -14,7 +14,7 @@ impl NacosNamingClient {
14
14
  /// Build a Naming Client.
15
15
  #[napi(constructor)]
16
16
  pub fn new(client_options: crate::ClientOptions) -> Result<NacosNamingClient> {
17
- let props = nacos_sdk::api::props::ClientProps::new()
17
+ let mut props = nacos_sdk::api::props::ClientProps::new()
18
18
  .server_addr(client_options.server_addr)
19
19
  .namespace(client_options.namespace)
20
20
  .app_name(
@@ -25,6 +25,11 @@ impl NacosNamingClient {
25
25
  .naming_push_empty_protection(client_options.naming_push_empty_protection.unwrap_or(true))
26
26
  .naming_load_cache_at_start(client_options.naming_load_cache_at_start.unwrap_or(false));
27
27
 
28
+ // endpoint takes priority over server_addr when both are provided
29
+ if let Some(endpoint) = client_options.endpoint {
30
+ props = props.endpoint(endpoint);
31
+ }
32
+
28
33
  // need enable_auth_plugin_http with username & password
29
34
  let is_enable_auth_http =
30
35
  client_options.username.is_some() && client_options.password.is_some();