Crate etcd_client

source ·
Expand description

An etcd v3 API client for Rust. It provides asynchronous client backed by tokio and tonic.

Supported APIs

  • KV
  • Watch
  • Lease
  • Auth
  • Maintenance
  • Cluster
  • Lock
  • Election

Usage

Add this to your Cargo.toml:

[dependencies]
etcd-client = "0.12"
tokio = { version = "1.0", 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"], None).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

Examples can be found in etcd-client/examples.

Feature Flags

  • tls: Enables the rustls-based TLS connection. Not enabled by default.
  • tls-roots: Adds system trust roots to rustls-based TLS connection using the rustls-native-certs crate. Not enabled by default.
  • pub-response-field: Exposes structs used to create regular etcd-client responses including internal protobuf representations. Useful for mocking. Not enabled by default.

Structs

Enums