Crate etcd_client
source ·Expand description
An etcd v3 API client for Rust. It provides asynchronous client backed by tokio and tonic.
Supported APIs
- KV
- Watch
- Lease
- Auth
- Maintenance
- Cluster
- Lock
- Election
Usage
Add this to your Cargo.toml:
[dependencies]
etcd-client = "0.12"
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 etcd-client/examples.
Feature Flags
tls: Enables therustls-based TLS connection. Not enabled by default.tls-roots: Adds system trust roots torustls-based TLS connection using therustls-native-certscrate. Not enabled by default.pub-response-field: Exposes structs used to create regularetcd-clientresponses including internal protobuf representations. Useful for mocking. Not enabled by default.
Structs
- Alarm member of respond.
- Options for
alarmoperation. - Response for
alarmoperation. - Client for Auth operations.
- Response for
AuthDisableoperation. - Response for
AuthEnableoperation. - Response for
Authenticateoperation. - Response for
Campaignoperation. - Certificate
tlsRepresents a X509 certificate. - Asynchronous
etcdclient using v3 API. - Client for Cluster operations.
- Options for
Compactoperation. - Response for
Compactoperation. - Transaction comparison.
- Options for
Connectoperation. - Response for
defragmentoperation. - Options for
Deleteoperation. - Response for
Deleteoperation. - Client for Elect operations.
- Watching event.
- Options for
Getoperation. - Response for
Getoperation. - Response for
hash_kvoperation. - Response for
hashoperation. - Identity
tlsRepresents a private key and X509 certificate. - Key-value pair.
- Client for KV operations.
- Leader key of election
- Response for
Leaderoperation. - Client for lease operations.
- Options for
Grantoperation. - Response for
Grantoperation. - Response for
KeepAliveoperation. - The lease keep alive response stream.
- The lease keep alive handle.
- Response for
Leasesoperation. - Response for
Revokeoperation. - Lease status.
- Options for
TimeToLiveoperation. - Response for
TimeToLiveoperation. - Client for Lock operations.
- Options for
Lockoperation. - Response for
Lockoperation. - Client for maintenance operations.
- Cluster member.
- Options for
MemberAddoperation. - Response for
MemberAddoperation. - Response for
MemberListoperation. - Response for
MemberPromoteoperation. - Response for
MemberRemoveoperation. - Response for
MemberUpdateoperation. - Response for
MoveLeaderoperation. - Response for
Observeoperation. - Role access permission.
- Options for
proclaimoperation. - Response for
Proclaimoperation. - Options for
Putoperation. - Response for
Putoperation. - Options for
resignoperation. - Response for
Resignoperation. - General
etcdresponse header. - Response for role add operation.
- Response for delete role operation.
- Response for get role operation.
- Response for grant role permission operation.
- Response for list role operation.
- Options for grant role permission operation.
- Response for revoke role permission operation.
- Response for
snapshotoperation. - Response for
snapshotoperation. - Response for
statusoperation. - TlsOptions
tlsConfigures TLS settings for endpoints. - Transaction of multiple operations.
- Transaction operation.
- Response for
Txnoperation. - Response for
Unlockoperation. - Options for
UserAddoperation. - Response for use add operation.
- Response for change user’s password operation.
- Response for delete user operation.
- Response for get user operation.
- Response for grant role for an user operation.
- Response for list user operation.
- Response for revoke role for an user operation.
- Client for watch operations.
- Options for
Watchoperation. - Response for
Watchoperation. - The watch response stream.
- The watching handle.
Enums
- Alarm action.
- Alarm type.
- Logical comparison operation.
- The error type for
etcdclient. - The kind of event.
- The ordering for sorted requests.
- The key-value field to sort.
- Transaction operation response.
- Watch filter type.