Skip to main content

Crate nacos_sdk

Crate nacos_sdk 

Source
Expand description

§Nacos in Rust

Thorough examples have been provided in our repository.

§Add Dependency

Add the dependency in Cargo.toml:

[dependencies]
nacos-sdk = { version = "0.8", 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()
 .await?;

§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()
 .await?;

Modules§

api
Nacos API