26 releases (2 stable)

1.0.1 Apr 10, 2023
1.0.0 Nov 23, 2022
1.0.0-alpha.3 Oct 23, 2022
1.0.0-alpha.1 Apr 14, 2022
0.0.0 Dec 26, 2018

#133 in Authentication

Download history 89/week @ 2024-01-08 118/week @ 2024-01-15 183/week @ 2024-01-22 124/week @ 2024-01-29 70/week @ 2024-02-05 78/week @ 2024-02-12 197/week @ 2024-02-19 111/week @ 2024-02-26 111/week @ 2024-03-04 182/week @ 2024-03-11 244/week @ 2024-03-18 123/week @ 2024-03-25 110/week @ 2024-04-01 148/week @ 2024-04-08 95/week @ 2024-04-15 85/week @ 2024-04-22

452 downloads per month
Used in sentinel-core

MIT license

72KB
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"
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–16MB
~201K SLoC