43 releases

0.14.0 Jul 10, 2024
0.12.4 Jan 1, 2024
0.12.3 Nov 21, 2023
0.11.1 May 3, 2023
0.1.1 Mar 28, 2020

#49 in Cryptography

Download history 24562/week @ 2024-07-20 24420/week @ 2024-07-27 25847/week @ 2024-08-03 22970/week @ 2024-08-10 23095/week @ 2024-08-17 25886/week @ 2024-08-24 21861/week @ 2024-08-31 22352/week @ 2024-09-07 13353/week @ 2024-09-14 19775/week @ 2024-09-21 19269/week @ 2024-09-28 21925/week @ 2024-10-05 27809/week @ 2024-10-12 26472/week @ 2024-10-19 28036/week @ 2024-10-26 28341/week @ 2024-11-02

114,281 downloads per month
Used in 74 crates (25 directly)

MIT/Apache

230KB
5.5K SLoC

etcd-client

Minimum rustc version Crate API

License: Apache OR License: MIT

An etcd v3 API client for Rust. It provides asynchronous client backed by tokio and tonic.

Features

  • etcd API v3
  • asynchronous

Supported APIs

  • KV
  • Watch
  • Lease
  • Auth
  • Maintenance
  • Cluster
  • Lock
  • Election
  • Namespace

Usage

Add this to your Cargo.toml:

[dependencies]
etcd-client = "0.14"
tokio = { version = "1.0", features = ["full"] }

To get started using etcd-client:

use etcd_client::{Client, Error};

#[tokio::main]
async fn main() -> Result<(), Error> {
    let mut client = Client::connect(["localhost:2379"], None).await?;
    // put kv
    client.put("foo", "bar", None).await?;
    // get kv
    let resp = client.get("foo", None).await?;
    if let Some(kv) = resp.kvs().first() {
        println!("Get kv: {{{}: {}}}", kv.key_str()?, kv.value_str()?);
    }

    Ok(())
}

Examples

Examples can be found in examples.

Feature Flags

  • tls: Enables the rustls-based TLS connection. Not enabled by default.
  • tls-roots: Adds system trust roots to rustls-based TLS connection using the rustls-native-certs crate. Not enabled by default.
  • pub-response-field: Exposes structs used to create regular etcd-client responses including internal protobuf representations. Useful for mocking. Not enabled by default.
  • tls-openssl: Enables the openssl-based TLS connections. This would make your binary dynamically link to libssl.
  • tls-openssl-vendored: Like tls-openssl, however compile openssl from source code and statically link to it.

Test

We test this library with etcd 3.5.

Notes that we use a fixed etcd server URI (localhost:2379) to connect to etcd server.

Rust version requirements

The minimum supported version is 1.70. The current etcd-client version is not guaranteed to build on Rust versions earlier than the minimum supported version.

License

Dual-licensed to be compatible with the Rust project.

Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in etcd-client by you, shall be licensed as Apache-2.0 and MIT, without any additional terms or conditions.

Dependencies

~5–17MB
~244K SLoC