Crate etcdv3client
source ·Expand description
A etcdv3 client written in Rust-lang.
use etcdv3client::{Client, Error};
#[tokio::main]
async fn main() -> Result<(), Error> {
let endpoint = "http://localhost:2379";
let auth: Option<(String, String)> = None;
let mut client = Client::new(vec![endpoint], auth).await?;
let key = "/hello";
// use convenience api under Client.
match client.get(key).await {
Ok(v) => {
println!("got `{}` => {:?}", key, String::from_utf8_lossy(&v));
}
Err(err) => {
if err.is_key_not_found() {
eprintln!("can not find `{}`", key);
} else {
eprintln!("etcd get failed: `{:?}`", err);
}
}
}
Ok(())
}