An etcd v3 API client for Rust. It provides asynchronous client backed by tokio and tonic.
- etcd API v3
- asynchronous
- KV
- Watch
- Lease
- Lock
- Cluster
- Maintenance
- Auth
- Election
Add this to your Cargo.toml
:
[dependencies]
etcd-client = "0.1"
tokio = { version = "0.2", features = ["full"] }
To get started using etcd-client
:
use etcd_client::{Client, Error};
#[tokio::main]
async fn main() -> Result<(), Error> {
let mut client = Client::connect(["localhost:2379"]).await?;
// put kv
client.put("foo", "bar", None).await?;
// get kv
let resp = client.get("foo", None).await?;
if let Some(kv) = resp.kvs().first() {
println!("Get kv: {{{}: {}}}", kv.key_str()?, kv.value_str()?);
}
Ok(())
}
Examples can be found in examples
.
We test this library using etcd 3.4.
Notes that we use a fixed etcd
server URI (localhost:2379) to connect to etcd server.
etcd-client
works on rust 1.39
and above as it requires support for the async_await
feature.
This project is licensed under the MIT license (LICENSE or http://opensource.org/licenses/MIT).
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in etcd-client
by you, shall be licensed as MIT, without any additional
terms or conditions.