Skip to content

Commit

Permalink
chore: doc hold Client for the app lifetime, log WARN 'connection hea…
Browse files Browse the repository at this point in the history
…lth check failed' (#223)
  • Loading branch information
CherishCai authored Apr 20, 2024
1 parent b8f0298 commit fc2bddb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ nacos-sdk = { version = "0.3", features = ["default"] }

### Usage of Config
```rust
// 请注意!一般情况下,应用下仅需一个 Config 客户端,而且需要长期持有直至应用停止。
// 因为它内部会初始化与服务端的长链接,后续的数据交互及变更订阅,都是实时地通过长链接告知客户端的。
let config_service = ConfigServiceBuilder::new(
ClientProps::new()
.server_addr("0.0.0.0:8848")
Expand Down Expand Up @@ -69,6 +71,8 @@ nacos-sdk = { version = "0.3", features = ["default"] }

### Usage of Naming
```rust
// 请注意!一般情况下,应用下仅需一个 Naming 客户端,而且需要长期持有直至应用停止。
// 因为它内部会初始化与服务端的长链接,后续的数据交互及变更订阅,都是实时地通过长链接告知客户端的。
let naming_service = NamingServiceBuilder::new(
ClientProps::new()
.server_addr("0.0.0.0:8848")
Expand Down
4 changes: 4 additions & 0 deletions examples/simple_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
;

// ---------- Config -------------
// 请注意!一般情况下,应用下仅需一个 Config 客户端,而且需要长期持有直至应用停止。
// 因为它内部会初始化与服务端的长链接,后续的数据交互及变更订阅,都是实时地通过长链接告知客户端的。
let config_service = ConfigServiceBuilder::new(client_props.clone())
.enable_auth_plugin_http() // TODO You can choose not to enable auth
.build()?;
Expand All @@ -53,6 +55,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}

// ---------- Naming -------------
// 请注意!一般情况下,应用下仅需一个 Naming 客户端,而且需要长期持有直至应用停止。
// 因为它内部会初始化与服务端的长链接,后续的数据交互及变更订阅,都是实时地通过长链接告知客户端的。
let naming_service = NamingServiceBuilder::new(client_props)
.enable_auth_plugin_http() // TODO You can choose not to enable auth
.build()?;
Expand Down
4 changes: 2 additions & 2 deletions src/common/remote/grpc/nacos_grpc_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ where

let response = GrpcMessage::<HealthCheckResponse>::from_payload(response);
if let Err(e) = response {
error!(
"connection health check failed convert to grpc message failed. {}",
warn!(
"connection health check failed convert to grpc message failed. If the retry is successful, please ignore it. {}",
e
);
return Err(ErrResult(
Expand Down

0 comments on commit fc2bddb

Please sign in to comment.