Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance: 0.3.x tonic instead of tikv/grpc-rs #160

Merged
merged 17 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type-complexity-threshold = 500
disallowed-methods = [
# Mutating environment variables in a multi-threaded context can cause data races.
# see https://github.com/rust-lang/rust/issues/90308 for details.
"std::env::set_var",
"std::env::remove_var",

# Use tokio::time::sleep instead.
"std::time::sleep",
]
disallowed-types = [
# Use tokio::time::Instant instead.
"std::time::Instant",
]
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Cargo.lock
# IDE
.idea
.vscode
.history
.DS_Store

# Customize
### google.protobuf.rs build by prost-build, exclude it because no content.
**/google.protobuf.rs
.DS_Store
.history
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 变更日志 | Change log

### 0.3.0
- Refactor: tonic instead of tikv/grpc-rs
- TODO

### 0.2.6

- 修复 `ServiceInfoUpdateTask` 丢失 auth header
Expand Down
26 changes: 14 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

[package]
name = "nacos-sdk"
version = "0.2.6"
version = "0.3.0-alpha"
edition = "2021"
authors = ["nacos-group", "CheirshCai <[email protected]>", "onewe <[email protected]>"]
license = "Apache-2.0"
Expand Down Expand Up @@ -49,34 +49,36 @@ async = ["async-trait"]
nacos-macro = { version = "0.1.0", path = "nacos-macro" }
thiserror = "1.0"
tokio = { version = "1.21", features = ["full"] }
#tokio-stream = { version = "0.1", features = ["net"] }

futures = "0.3"
grpcio = { version = "0.12", default-features = false, features = ["prost-codec"] }
prost = "0.11"
prost-types = "0.11"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_repr = "0.1"
lazy_static = "1.4"
#crossbeam = "0"
#async_once = "0"

#opentelemetry = "0"
tracing = "0.1"
local_ipaddress = "0.1.3"
rand = "0.8.5"
url="2.3.1"

# now only for feature="auth-by-http"
reqwest = { version = "0.11", default-features = false, features = [], optional = true }
async-trait = {version = "0.1", optional = true}
# for feature="async"
async-trait = { version = "0.1", optional = true }

async-stream = "0.3.5"
tonic = "0.9"
tower = { version = "0.4.13", features = ["filter", "log"] }
pin-project = "1.0.12"
futures-util = "0.3.28"
want = "0.3.0"
dashmap = "5.4.0"
home = "0.5.4"

[dev-dependencies]
grpcio-compiler = { version = "0.12", default-features = false, features = ["prost-codec"] }
prost-build = "0.11"

[dev-dependencies]
tracing-subscriber = { version = "0.3", features = ["default"] }
tonic-build = "0.9"

[[example]]
name = "simple_app"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Add the dependency in `Cargo.toml`:
```toml
[dependencies]
# If you need async API, which can be enabled via `features = ["async"]`
nacos-sdk = { version = "0.2", features = ["default"] }
nacos-sdk = { version = "0.3", features = ["default"] }
```

### Usage of Config
Expand Down
6 changes: 2 additions & 4 deletions examples/simple_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use nacos_sdk::api::naming::{
NamingChangeEvent, NamingEventListener, NamingService, NamingServiceBuilder, ServiceInstance,
};
use nacos_sdk::api::props::ClientProps;
use std::time::Duration;
use tokio::time::sleep;

/// enable https auth run with command:
/// cargo run --example simple_app --features default,tls
Expand Down Expand Up @@ -73,7 +71,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Some(constants::DEFAULT_GROUP.to_string()),
vec![service_instance1],
);
sleep(Duration::from_millis(111)).await;
tokio::time::sleep(tokio::time::Duration::from_millis(666)).await;

let instances_ret = naming_service.get_all_instances(
"test-service".to_string(),
Expand All @@ -86,7 +84,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Err(err) => tracing::error!("naming get_all_instances error {:?}", err),
}

sleep(Duration::from_secs(300)).await;
tokio::time::sleep(tokio::time::Duration::from_secs(300)).await;

Ok(())
}
Expand Down
Loading