4 stable releases

1.2.2 Sep 14, 2024
1.2.1 Aug 27, 2024
1.2.0 Jul 9, 2024
1.1.0 Jul 1, 2024

#500 in Database interfaces

Download history 12/week @ 2024-07-24 7/week @ 2024-07-31 117/week @ 2024-08-21 51/week @ 2024-08-28 144/week @ 2024-09-11 22/week @ 2024-09-18 34/week @ 2024-09-25 8/week @ 2024-10-02

280 downloads per month

MIT license

77KB
2K SLoC

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.

Dependencies

~5–14MB
~185K SLoC