25 releases (1 stable)

Uses new Rust 2021

1.0.0 Nov 23, 2022
1.0.0-alpha.1 Apr 14, 2022
1.0.0-alpha.0 Mar 9, 2022
0.6.0 Dec 19, 2021
0.0.0 Dec 26, 2018

#43 in Asynchronous

Download history 178/week @ 2022-08-15 231/week @ 2022-08-22 225/week @ 2022-08-29 252/week @ 2022-09-05 287/week @ 2022-09-12 271/week @ 2022-09-19 376/week @ 2022-09-26 298/week @ 2022-10-03 291/week @ 2022-10-10 355/week @ 2022-10-17 449/week @ 2022-10-24 416/week @ 2022-10-31 460/week @ 2022-11-07 392/week @ 2022-11-14 378/week @ 2022-11-21 243/week @ 2022-11-28

1,508 downloads per month
Used in sentinel-core

MIT license

71KB
2K SLoC

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
    • RoleAdd
    • RoleGrantPermission
    • UserAdd
    • UserGrantRole
    • AuthEnable
    • AuthDisable
  • Cluster
    • MemberAdd
    • MemberRemove
    • MemberUpdate
    • MemberList
  • Maintenance
    • Alarm
    • Status
    • Defragment
    • Hash
    • Snapshot
    • MoveLeader

Usage

Add following dependencies in your project cargo.toml:

[dependencies]
etcd-rs = "1.0.0"
use etcd_rs::Client;

#[tokio::main]
async fn main() {
    let cli = Client::connect(ClientConfig {
        endpoints: [
            "http://127.0.0.1:12379",
            "http://127.0.0.1:22379",
            "http://127.0.0.1:32379",
        ],
        ..Default::default()
    }).await;
    
    cli.put(("foo", "bar")).await.expect("put kv");
    
    let kvs = cli.get("foo").await.expect("get kv").take_kvs();
    assert_eq!(kvs.len(), 1);
}

Development

requirements:

  • Makefile
  • docker
  • docker-compose

Start local etcd cluster

make setup-etcd-cluster

stop cluster

make teardown-etcd-cluster

Run tests

make test

for specified case:

TEST_CASE=test_put_error make test-one

License

This project is licensed under the MIT license.

Dependencies

~5–13MB
~222K SLoC