ya-etcd-rs 1.3.1

etcd client for rust
Documentation

yet another etcd client for Rust

An etcd (API v3) client for Rust backed by tokio and tonic.

Supported APIs

  • KV
    • Put
    • Range
    • Delete
    • Transaction
    • Compact
  • Lease
    • Grant
    • Revoke
    • KeepAlive
    • TimeToLive
  • Watch
    • WatchCreate
    • WatchCancel
  • Auth
    • Authenticate
    • AuthStatus
    • AuthEnable
    • AuthDisable
    • RoleAdd
    • RoleDelete
    • RoleList
    • RoleGrantPermission
    • UserAdd
    • UserDelete
    • UserGrantRole
  • Cluster
    • MemberAdd
    • MemberRemove
    • MemberUpdate
    • MemberList
  • Maintenance
    • Alarm
    • Status
    • Defragment
    • Hash
    • Snapshot
    • MoveLeader

MSRV

  • 1.1.0 to 1.3.1 - Rust 1.75

Usage

Add following dependencies in your project cargo.toml:

[dependencies]
ya-etcd-rs = "1.3"
use ya_etcd_rs::{Client, ClientConfig, KeyValueOp, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let cli = Client::new(ClientConfig::new([
        "http://127.0.0.1:12379".into(),
        "http://127.0.0.1:22379".into(),
        "http://127.0.0.1:32379".into(),
    ]))
    .await?;

    cli.put(("foo", "bar")).await.expect("put kv");

    let kvs = cli.get("foo").await.expect("get kv").kvs;
    assert_eq!(kvs.len(), 1);
    Ok(())
}

Development

requirements:

  • Makefile
  • docker
  • docker compose

Start local etcd cluster

make setup-etcd-cluster

stop cluster

make teardown-etcd-cluster

for specified case:

TEST_CASE=test_put_error make test-one

License

This project is licensed under the MIT license.