shell
cargo install luoshu
不开放管理web接口
shell
luoshu
开放管理web接口
shell
luoshu --web
引入洛书客户端 ```toml [workspace.dependencies]
luoshurustclient = "0.1.0"
订阅配置信息,并注册服务到洛书并编写业务代码
rust
use std::thread::sleep;
use luoshurustclient::LuoshuClient;
struct Config {
test1: String,
test2: Vec
async fn itworks() -> LuoshuClientResult<()> { let mut client = LuoshuClient::new(15666, "testrustserver".tostring(), None).await; client .subscribeconfig( "testconfig2".to_string(), |config: Config| println!("config changed:{:#?}", config), None, ) .await?; tokio::spawn(async move { client.registry().await.expect("TODO: panic message"); });
// 此处使用无限循环模拟服务的持续运行
loop {
println!("sleep");
sleep(Duration::from_secs(10))
}
} ```