Expand description
§Nacos in Rust
Thorough examples have been provided in our repository.
§Add Dependency
Add the dependency in Cargo.toml
:
- If you need sync API, maybe
futures::executor::block_on(future_fn)
[dependencies]
nacos-sdk = { version = "0.4", features = ["default"] }
§General Configurations and Initialization
Nacos needs to be initialized. Please see the api
module.
§Example of Config
ⓘ
let config_service = nacos_sdk::api::config::ConfigServiceBuilder::new(
nacos_sdk::api::props::ClientProps::new()
.server_addr("127.0.0.1:8848")
// Attention! "public" is "", it is recommended to customize the namespace with clear meaning.
.namespace("")
.app_name("todo-your-app-name"),
)
.build()?;
§Example of Naming
ⓘ
let naming_service = nacos_sdk::api::naming::NamingServiceBuilder::new(
nacos_sdk::api::props::ClientProps::new()
.server_addr("127.0.0.1:8848")
// Attention! "public" is "", it is recommended to customize the namespace with clear meaning.
.namespace("")
.app_name("todo-your-app-name"),
)
.build()?;
Modules§
- Nacos API