nacos-sdk-rust-binding-node 0.0.1-PRE → 0.0.1
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 +1 -0
- package/package.json +15 -15
- package/src/config.rs +1 -1
- package/src/lib.rs +24 -21
- package/src/naming.rs +1 -1
package/Cargo.toml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nacos-sdk-rust-binding-node",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"napi": {
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
},
|
|
44
44
|
"packageManager": "yarn@3.4.1",
|
|
45
45
|
"optionalDependencies": {
|
|
46
|
-
"nacos-sdk-rust-binding-node-win32-x64-msvc": "0.0.1
|
|
47
|
-
"nacos-sdk-rust-binding-node-darwin-x64": "0.0.1
|
|
48
|
-
"nacos-sdk-rust-binding-node-linux-x64-gnu": "0.0.1
|
|
49
|
-
"nacos-sdk-rust-binding-node-darwin-arm64": "0.0.1
|
|
50
|
-
"nacos-sdk-rust-binding-node-android-arm64": "0.0.1
|
|
51
|
-
"nacos-sdk-rust-binding-node-linux-arm64-gnu": "0.0.1
|
|
52
|
-
"nacos-sdk-rust-binding-node-linux-arm64-musl": "0.0.1
|
|
53
|
-
"nacos-sdk-rust-binding-node-win32-arm64-msvc": "0.0.1
|
|
54
|
-
"nacos-sdk-rust-binding-node-linux-arm-gnueabihf": "0.0.1
|
|
55
|
-
"nacos-sdk-rust-binding-node-linux-x64-musl": "0.0.1
|
|
56
|
-
"nacos-sdk-rust-binding-node-freebsd-x64": "0.0.1
|
|
57
|
-
"nacos-sdk-rust-binding-node-win32-ia32-msvc": "0.0.1
|
|
58
|
-
"nacos-sdk-rust-binding-node-android-arm-eabi": "0.0.1
|
|
59
|
-
"nacos-sdk-rust-binding-node-darwin-universal": "0.0.1
|
|
46
|
+
"nacos-sdk-rust-binding-node-win32-x64-msvc": "0.0.1",
|
|
47
|
+
"nacos-sdk-rust-binding-node-darwin-x64": "0.0.1",
|
|
48
|
+
"nacos-sdk-rust-binding-node-linux-x64-gnu": "0.0.1",
|
|
49
|
+
"nacos-sdk-rust-binding-node-darwin-arm64": "0.0.1",
|
|
50
|
+
"nacos-sdk-rust-binding-node-android-arm64": "0.0.1",
|
|
51
|
+
"nacos-sdk-rust-binding-node-linux-arm64-gnu": "0.0.1",
|
|
52
|
+
"nacos-sdk-rust-binding-node-linux-arm64-musl": "0.0.1",
|
|
53
|
+
"nacos-sdk-rust-binding-node-win32-arm64-msvc": "0.0.1",
|
|
54
|
+
"nacos-sdk-rust-binding-node-linux-arm-gnueabihf": "0.0.1",
|
|
55
|
+
"nacos-sdk-rust-binding-node-linux-x64-musl": "0.0.1",
|
|
56
|
+
"nacos-sdk-rust-binding-node-freebsd-x64": "0.0.1",
|
|
57
|
+
"nacos-sdk-rust-binding-node-win32-ia32-msvc": "0.0.1",
|
|
58
|
+
"nacos-sdk-rust-binding-node-android-arm-eabi": "0.0.1",
|
|
59
|
+
"nacos-sdk-rust-binding-node-darwin-universal": "0.0.1"
|
|
60
60
|
}
|
|
61
61
|
}
|
package/src/config.rs
CHANGED
|
@@ -23,7 +23,7 @@ impl NacosConfigClient {
|
|
|
23
23
|
>,
|
|
24
24
|
) -> Result<NacosConfigClient> {
|
|
25
25
|
// print to console or file
|
|
26
|
-
crate::
|
|
26
|
+
let _ = crate::init_logger();
|
|
27
27
|
|
|
28
28
|
let props = nacos_sdk::api::props::ClientProps::new()
|
|
29
29
|
.server_addr(client_options.server_addr)
|
package/src/lib.rs
CHANGED
|
@@ -8,29 +8,32 @@ pub fn sum(a: i32, b: i32) -> i32 {
|
|
|
8
8
|
a + b
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
lazy_static::lazy_static! {
|
|
12
|
+
static ref LOG_GUARD: tracing_appender::non_blocking::WorkerGuard = {
|
|
13
|
+
let home_dir = match std::env::var("HOME") {
|
|
14
|
+
Ok(dir) => dir,
|
|
15
|
+
Err(_) => "/tmp".to_string(),
|
|
16
|
+
};
|
|
17
|
+
let file_appender = tracing_appender::rolling::daily(home_dir + "/logs/nacos", "nacos.log");
|
|
18
|
+
let (non_blocking, guard) = tracing_appender::non_blocking(file_appender);
|
|
19
|
+
|
|
20
|
+
tracing_subscriber::fmt()
|
|
21
|
+
.with_writer(non_blocking)
|
|
22
|
+
.with_level(true)
|
|
23
|
+
.with_thread_names(true)
|
|
24
|
+
.with_thread_ids(true)
|
|
25
|
+
.with_line_number(true)
|
|
26
|
+
.with_max_level(tracing_subscriber::filter::LevelFilter::INFO)
|
|
27
|
+
.init();
|
|
28
|
+
|
|
29
|
+
guard
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
}
|
|
12
33
|
|
|
13
34
|
/// log print to console or file
|
|
14
|
-
fn
|
|
15
|
-
|
|
16
|
-
let home_dir = match std::env::var("HOME") {
|
|
17
|
-
Ok(dir) => dir,
|
|
18
|
-
Err(_) => "/tmp".to_string(),
|
|
19
|
-
};
|
|
20
|
-
// FIXME log to file, now there are files but no content.
|
|
21
|
-
let file_appender = tracing_appender::rolling::daily(home_dir + "/logs/nacos", "nacos.log");
|
|
22
|
-
let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);
|
|
23
|
-
|
|
24
|
-
tracing_subscriber::fmt()
|
|
25
|
-
.with_writer(non_blocking)
|
|
26
|
-
.with_thread_names(true)
|
|
27
|
-
.with_file(true)
|
|
28
|
-
.with_level(true)
|
|
29
|
-
.with_line_number(true)
|
|
30
|
-
.with_thread_ids(true)
|
|
31
|
-
.with_max_level(tracing_subscriber::filter::LevelFilter::INFO)
|
|
32
|
-
.init();
|
|
33
|
-
});
|
|
35
|
+
fn init_logger() -> &'static tracing_appender::non_blocking::WorkerGuard {
|
|
36
|
+
&LOG_GUARD
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
#[napi(object)]
|
package/src/naming.rs
CHANGED
|
@@ -15,7 +15,7 @@ impl NacosNamingClient {
|
|
|
15
15
|
#[napi(constructor)]
|
|
16
16
|
pub fn new(client_options: crate::ClientOptions) -> Result<NacosNamingClient> {
|
|
17
17
|
// print to console or file
|
|
18
|
-
crate::
|
|
18
|
+
let _ = crate::init_logger();
|
|
19
19
|
|
|
20
20
|
let props = nacos_sdk::api::props::ClientProps::new()
|
|
21
21
|
.server_addr(client_options.server_addr)
|