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.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 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-certs
crate. Not enabled by default.pub-response-field
: Exposes structs used to create regularetcd-client
responses including internal protobuf representations. Useful for mocking. Not enabled by default.
Structs§
- Alarm member of respond.
- Options for
alarm
operation. - Response for
alarm
operation. - Client for Auth operations.
- Response for
AuthDisable
operation. - Response for
AuthEnable
operation. - Response for
Authenticate
operation. - Response for
Campaign
operation. - Certificate
tls
Represents a X509 certificate. - Asynchronous
etcd
client using v3 API. - Client for Cluster operations.
- Options for
Compact
operation. - Response for
Compact
operation. - Transaction comparison.
- Options for
Connect
operation. - Response for
defragment
operation. - Options for
Delete
operation. - Response for
Delete
operation. - Client for Elect operations.
- Watching event.
- Options for
Get
operation. - Response for
Get
operation. - Response for
hash_kv
operation. - Response for
hash
operation. - Identity
tls
Represents a private key and X509 certificate. - Key-value pair.
- Client for KV operations.
- Leader key of election
- Response for
Leader
operation. - Client for lease operations.
- Options for
Grant
operation. - Response for
Grant
operation. - Response for
KeepAlive
operation. - The lease keep alive response stream.
- The lease keep alive handle.
- Response for
Leases
operation. - Response for
Revoke
operation. - Lease status.
- Options for
TimeToLive
operation. - Response for
TimeToLive
operation. - Client for Lock operations.
- Options for
Lock
operation. - Response for
Lock
operation. - Client for maintenance operations.
- Cluster member.
- Options for
MemberAdd
operation. - Response for
MemberAdd
operation. - Response for
MemberList
operation. - Response for
MemberPromote
operation. - Response for
MemberRemove
operation. - Response for
MemberUpdate
operation. - Response for
MoveLeader
operation. - Response for
Observe
operation. - Role access permission.
- Options for
proclaim
operation. - Response for
Proclaim
operation. - Options for
Put
operation. - Response for
Put
operation. - Options for
resign
operation. - Response for
Resign
operation. - General
etcd
response 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
snapshot
operation. - Response for
snapshot
operation. - Response for
status
operation. - TlsOptions
tls
Configures TLS settings for endpoints. - Transaction of multiple operations.
- Transaction operation.
- Response for
Txn
operation. - Response for
Unlock
operation. - Options for
UserAdd
operation. - 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
Watch
operation. - Response for
Watch
operation. - The watch response stream.
- The watching handle.
Enums§
- Alarm action.
- Alarm type.
- Logical comparison operation.
- The error type for
etcd
client. - The kind of event.
- The ordering for sorted requests.
- The key-value field to sort.
- Transaction operation response.
- Watch filter type.