ya-etcd-rs

Crates.ioya-etcd-rs
lib.rsya-etcd-rs
version1.2.2
sourcesrc
created_at2024-07-01 03:10:49.752067
updated_at2024-09-14 09:05:10.72685
descriptionetcd client for rust
homepagehttps://github.com/Fiekers/etcd-rs
repositoryhttps://github.com/Fiekers/etcd-rs
max_upload_size
id1288330
size151,679
fiekers (Fiekers)

documentation

README

yet another etcd client for Rust

github crates.io docs.rs build status dependency status

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

Rust Version

ya-etcd-rs's MSRV is 1.75.

$ rustup update
$ cargo build

Usage

Add following dependencies in your project cargo.toml:

[dependencies]
ya-etcd-rs = "1.2"
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.

Commit count: 220

cargo fmt