Skip to content

Commit 852c584

Browse files
authored
bump: upgrade 0.5.0, rust-edition=2024, MSRV=1.80 (#255)
- 增强: rust-edition=2024, MSRV=1.80 - 增强: ConfigService / NamingService 改为 struct 而无需 Box 包裹
1 parent f58a743 commit 852c584

37 files changed

+400
-240
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# 变更日志 | Change log
22

3+
### 0.5.0
4+
5+
- 增强: rust-edition=2024, MSRV=1.80
6+
- 增强: ConfigService / NamingService 改为 struct 而无需 Box<dyn> 包裹
7+
8+
---
9+
10+
- Enhance: rust-edition=2024, MSRV=1.80
11+
- Enhance: ConfigService / NamingService changed to struct without Box<dyn> wrapping
12+
13+
314
### 0.4.3
415

516
- 功能: 提供 Aliyun ram AuthPlugin (#245),通过 `features = ["auth-by-aliyun"]` 开启

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
[package]
2020
name = "nacos-sdk"
21-
version = "0.4.3"
22-
edition = "2021"
21+
version = "0.5.0"
22+
edition = "2024"
2323
authors = ["nacos-group", "CheirshCai <[email protected]>", "onewe <[email protected]>"]
2424
license = "Apache-2.0"
2525
readme = "README.md"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Add the dependency in `Cargo.toml`:
2323
```toml
2424
[dependencies]
2525
# If you need sync API, maybe `futures::executor::block_on(future_fn)`
26-
nacos-sdk = { version = "0.4", features = ["default"] }
26+
nacos-sdk = { version = "0.5", features = ["default"] }
2727
```
2828

2929
### Usage of Config

examples/aliyun_ram_app.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use nacos_sdk::api::config::{ConfigService, ConfigServiceBuilder};
2-
use nacos_sdk::api::naming::{NamingService, NamingServiceBuilder, ServiceInstance};
1+
use nacos_sdk::api::config::ConfigServiceBuilder;
2+
use nacos_sdk::api::naming::{NamingServiceBuilder, ServiceInstance};
33
use nacos_sdk::api::props::ClientProps;
44
use std::time::Duration;
55
use tokio::time::sleep;
@@ -33,7 +33,7 @@ async fn run_naming_demo() {
3333
let server_addr = "localhost:8848";
3434

3535
/// NamingService
36-
let mut naming_client = NamingServiceBuilder::new(ClientProps::new().server_addr(server_addr))
36+
let naming_client = NamingServiceBuilder::new(ClientProps::new().server_addr(server_addr))
3737
.enable_auth_plugin_aliyun()
3838
.build()
3939
.unwrap();
@@ -68,7 +68,7 @@ async fn run_config_demo() {
6868
let server_addr = "localhost:8848";
6969

7070
/// Config service
71-
let mut config_client = ConfigServiceBuilder::new(ClientProps::new().server_addr(server_addr))
71+
let config_client = ConfigServiceBuilder::new(ClientProps::new().server_addr(server_addr))
7272
.enable_auth_plugin_aliyun()
7373
.build()
7474
.unwrap();

examples/lazy_app.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ static CLIENT_PROPS: LazyLock<ClientProps> = LazyLock::new(|| {
2222

2323
// 请注意!一般情况下,应用下仅需一个 Config 客户端,而且需要长期持有直至应用停止。
2424
// 因为它内部会初始化与服务端的长链接,后续的数据交互及变更订阅,都是实时地通过长链接告知客户端的。
25-
static CONFIG_SERVICE: LazyLock<Box<dyn ConfigService>> = LazyLock::new(|| {
25+
static CONFIG_SERVICE: LazyLock<ConfigService> = LazyLock::new(|| {
2626
let config_service = ConfigServiceBuilder::new(CLIENT_PROPS.clone())
2727
.enable_auth_plugin_http() // TODO You can choose not to enable auth
2828
.build()
2929
.unwrap();
30-
Box::new(config_service)
30+
config_service
3131
});
3232

3333
// 请注意!一般情况下,应用下仅需一个 Naming 客户端,而且需要长期持有直至应用停止。
3434
// 因为它内部会初始化与服务端的长链接,后续的数据交互及变更订阅,都是实时地通过长链接告知客户端的。
35-
static NAMING_SERVICE: LazyLock<Box<dyn NamingService>> = LazyLock::new(|| {
35+
static NAMING_SERVICE: LazyLock<NamingService> = LazyLock::new(|| {
3636
let naming_service = NamingServiceBuilder::new(CLIENT_PROPS.clone())
3737
.enable_auth_plugin_http() // TODO You can choose not to enable auth
3838
.build()
3939
.unwrap();
40-
Box::new(naming_service)
40+
naming_service
4141
});
4242

4343
/// enable https auth run with command:

examples/simple_app.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
use nacos_sdk::api::config::{
2-
ConfigChangeListener, ConfigResponse, ConfigService, ConfigServiceBuilder,
3-
};
1+
use nacos_sdk::api::config::{ConfigChangeListener, ConfigResponse, ConfigServiceBuilder};
42
use nacos_sdk::api::constants;
53
use nacos_sdk::api::naming::{
6-
NamingChangeEvent, NamingEventListener, NamingService, NamingServiceBuilder, ServiceInstance,
4+
NamingChangeEvent, NamingEventListener, NamingServiceBuilder, ServiceInstance,
75
};
86
use nacos_sdk::api::props::ClientProps;
97

src/_.rs

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// This file is @generated by prost-build.
2-
#[allow(clippy::derive_partial_eq_without_eq)]
32
#[derive(Clone, PartialEq, ::prost::Message)]
43
pub struct Metadata {
54
#[prost(string, tag = "3")]
@@ -10,7 +9,6 @@ pub struct Metadata {
109
pub headers:
1110
::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
1211
}
13-
#[allow(clippy::derive_partial_eq_without_eq)]
1412
#[derive(Clone, PartialEq, ::prost::Message)]
1513
pub struct Payload {
1614
#[prost(message, optional, tag = "2")]
@@ -20,7 +18,13 @@ pub struct Payload {
2018
}
2119
/// Generated client implementations.
2220
pub mod request_client {
23-
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
21+
#![allow(
22+
unused_variables,
23+
dead_code,
24+
missing_docs,
25+
clippy::wildcard_imports,
26+
clippy::let_unit_value
27+
)]
2428
use tonic::codegen::http::Uri;
2529
use tonic::codegen::*;
2630
#[derive(Debug, Clone)]
@@ -42,8 +46,8 @@ pub mod request_client {
4246
where
4347
T: tonic::client::GrpcService<tonic::body::BoxBody>,
4448
T::Error: Into<StdError>,
45-
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
46-
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
49+
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
50+
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
4751
{
4852
pub fn new(inner: T) -> Self {
4953
let inner = tonic::client::Grpc::new(inner);
@@ -61,13 +65,13 @@ pub mod request_client {
6165
F: tonic::service::Interceptor,
6266
T::ResponseBody: Default,
6367
T: tonic::codegen::Service<
64-
http::Request<tonic::body::BoxBody>,
65-
Response = http::Response<
66-
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
68+
http::Request<tonic::body::BoxBody>,
69+
Response = http::Response<
70+
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
71+
>,
6772
>,
68-
>,
6973
<T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
70-
Into<StdError> + Send + Sync,
74+
Into<StdError> + std::marker::Send + std::marker::Sync,
7175
{
7276
RequestClient::new(InterceptedService::new(inner, interceptor))
7377
}
@@ -108,10 +112,7 @@ pub mod request_client {
108112
request: impl tonic::IntoRequest<super::Payload>,
109113
) -> std::result::Result<tonic::Response<super::Payload>, tonic::Status> {
110114
self.inner.ready().await.map_err(|e| {
111-
tonic::Status::new(
112-
tonic::Code::Unknown,
113-
format!("Service was not ready: {}", e.into()),
114-
)
115+
tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
115116
})?;
116117
let codec = tonic::codec::ProstCodec::default();
117118
let path = http::uri::PathAndQuery::from_static("/Request/request");
@@ -124,7 +125,13 @@ pub mod request_client {
124125
}
125126
/// Generated client implementations.
126127
pub mod bi_request_stream_client {
127-
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
128+
#![allow(
129+
unused_variables,
130+
dead_code,
131+
missing_docs,
132+
clippy::wildcard_imports,
133+
clippy::let_unit_value
134+
)]
128135
use tonic::codegen::http::Uri;
129136
use tonic::codegen::*;
130137
#[derive(Debug, Clone)]
@@ -146,8 +153,8 @@ pub mod bi_request_stream_client {
146153
where
147154
T: tonic::client::GrpcService<tonic::body::BoxBody>,
148155
T::Error: Into<StdError>,
149-
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
150-
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
156+
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
157+
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
151158
{
152159
pub fn new(inner: T) -> Self {
153160
let inner = tonic::client::Grpc::new(inner);
@@ -165,13 +172,13 @@ pub mod bi_request_stream_client {
165172
F: tonic::service::Interceptor,
166173
T::ResponseBody: Default,
167174
T: tonic::codegen::Service<
168-
http::Request<tonic::body::BoxBody>,
169-
Response = http::Response<
170-
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
175+
http::Request<tonic::body::BoxBody>,
176+
Response = http::Response<
177+
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
178+
>,
171179
>,
172-
>,
173180
<T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
174-
Into<StdError> + Send + Sync,
181+
Into<StdError> + std::marker::Send + std::marker::Sync,
175182
{
176183
BiRequestStreamClient::new(InterceptedService::new(inner, interceptor))
177184
}
@@ -215,10 +222,7 @@ pub mod bi_request_stream_client {
215222
tonic::Status,
216223
> {
217224
self.inner.ready().await.map_err(|e| {
218-
tonic::Status::new(
219-
tonic::Code::Unknown,
220-
format!("Service was not ready: {}", e.into()),
221-
)
225+
tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
222226
})?;
223227
let codec = tonic::codec::ProstCodec::default();
224228
let path = http::uri::PathAndQuery::from_static("/BiRequestStream/requestBiStream");

0 commit comments

Comments
 (0)