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 - Alarm member of respond.
- Alarm
Options - Options for
alarm
operation. - Alarm
Response - Response for
alarm
operation. - Auth
Client - Client for Auth operations.
- Auth
Disable Response - Response for
AuthDisable
operation. - Auth
Enable Response - Response for
AuthEnable
operation. - Authenticate
Response - Response for
Authenticate
operation. - Campaign
Response - Response for
Campaign
operation. - Certificate
tls
- Represents a X509 certificate.
- Client
- Asynchronous
etcd
client using v3 API. - Cluster
Client - Client for Cluster operations.
- Compaction
Options - Options for
Compact
operation. - Compaction
Response - Response for
Compact
operation. - Compare
- Transaction comparison.
- Connect
Options - Options for
Connect
operation. - Defragment
Response - Response for
defragment
operation. - Delete
Options - Options for
Delete
operation. - Delete
Response - Response for
Delete
operation. - Election
Client - Client for Elect operations.
- Event
- Watching event.
- GetOptions
- Options for
Get
operation. - GetResponse
- Response for
Get
operation. - Hash
KvResponse - Response for
hash_kv
operation. - Hash
Response - Response for
hash
operation. - Identity
tls
- Represents a private key and X509 certificate.
- KeyValue
- Key-value pair.
- KvClient
- Client for KV operations.
- KvClient
Prefix - Leader
Key - Leader key of election
- Leader
Response - Response for
Leader
operation. - Lease
Client - Client for lease operations.
- Lease
Client Prefix - Lease
Grant Options - Options for
Grant
operation. - Lease
Grant Response - Response for
Grant
operation. - Lease
Keep Alive Response - Response for
KeepAlive
operation. - Lease
Keep Alive Stream - The lease keep alive response stream.
- Lease
Keeper - The lease keep alive handle.
- Lease
Leases Response - Response for
Leases
operation. - Lease
Revoke Response - Response for
Revoke
operation. - Lease
Status - Lease status.
- Lease
Time ToLive Options - Options for
TimeToLive
operation. - Lease
Time ToLive Response - Response for
TimeToLive
operation. - Lock
Client - Client for Lock operations.
- Lock
Options - Options for
Lock
operation. - Lock
Response - Response for
Lock
operation. - Maintenance
Client - Client for maintenance operations.
- Member
- Cluster member.
- Member
AddOptions - Options for
MemberAdd
operation. - Member
AddResponse - Response for
MemberAdd
operation. - Member
List Response - Response for
MemberList
operation. - Member
Promote Response - Response for
MemberPromote
operation. - Member
Remove Response - Response for
MemberRemove
operation. - Member
Update Response - Response for
MemberUpdate
operation. - Move
Leader Response - Response for
MoveLeader
operation. - Observe
Stream - Response for
Observe
operation. - Permission
- Role access permission.
- Proclaim
Options - Options for
proclaim
operation. - Proclaim
Response - Response for
Proclaim
operation. - PutOptions
- Options for
Put
operation. - PutResponse
- Response for
Put
operation. - Resign
Options - Options for
resign
operation. - Resign
Response - Response for
Resign
operation. - Response
Header - General
etcd
response header. - Role
AddResponse - Response for role add operation.
- Role
Delete Response - Response for delete role operation.
- Role
GetResponse - Response for get role operation.
- Role
Grant Permission Response - Response for grant role permission operation.
- Role
List Response - Response for list role operation.
- Role
Revoke Permission Options - Options for grant role permission operation.
- Role
Revoke Permission Response - Response for revoke role permission operation.
- Snapshot
Response - Response for
snapshot
operation. - Snapshot
Streaming - Response for
snapshot
operation. - Status
Response - Response for
status
operation. - TlsOptions
tls
- Configures TLS settings for endpoints.
- Txn
- Transaction of multiple operations.
- TxnOp
- Transaction operation.
- TxnResponse
- Response for
Txn
operation. - Unlock
Response - Response for
Unlock
operation. - User
AddOptions - Options for
UserAdd
operation. - User
AddResponse - Response for use add operation.
- User
Change Password Response - Response for change user’s password operation.
- User
Delete Response - Response for delete user operation.
- User
GetResponse - Response for get user operation.
- User
Grant Role Response - Response for grant role for an user operation.
- User
List Response - Response for list user operation.
- User
Revoke Role Response - Response for revoke role for an user operation.
- Watch
Client - Client for watch operations.
- Watch
Options - Options for
Watch
operation. - Watch
Response - Response for
Watch
operation. - Watch
Stream - The watch response stream.
- Watcher
- The watching handle.
Enums§
- Alarm
Action - Alarm action.
- Alarm
Type - Alarm type.
- Compare
Op - Logical comparison operation.
- Error
- The error type for
etcd
client. - Event
Type - The kind of event.
- Permission
Type - Sort
Order - The ordering for sorted requests.
- Sort
Target - The key-value field to sort.
- TxnOp
Response - Transaction operation response.
- Watch
Filter Type - Watch filter type.