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.16"
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.tls-openssl: Enables theopenssl-based TLS connections. This would make your binary dynamically link tolibssl.tls-openssl-vendored: Liketls-openssl, however compile openssl from source code and statically link to it.build-server: Builds a server variant of the etcd protobuf and re-exports it under the sameprotopackage as thepub-response-fieldfeature does.raw-channel: Allows the caller to construct the underlying Tonic channel used by the client.
Structs§
- Alarm
Member - Alarm member of respond.
- Alarm
Options - Options for
alarmoperation. - Alarm
Response - Response for
alarmoperation. - Auth
Client - Client for Auth operations.
- Auth
Disable Response - Response for
AuthDisableoperation. - Auth
Enable Response - Response for
AuthEnableoperation. - Authenticate
Response - Response for
Authenticateoperation. - Campaign
Response - Response for
Campaignoperation. - Certificate
tls - Represents a X509 certificate.
- Client
- Asynchronous
etcdclient using v3 API. - Cluster
Client - Client for Cluster operations.
- Compaction
Options - Options for
Compactoperation. - Compaction
Response - Response for
Compactoperation. - Compare
- Transaction comparison.
- Connect
Options - Options for
Connectoperation. - Defragment
Response - Response for
defragmentoperation. - Delete
Options - Options for
Deleteoperation. - Delete
Response - Response for
Deleteoperation. - Election
Client - Client for Elect operations.
- Event
- Watching event.
- GetOptions
- Options for
Getoperation. - GetResponse
- Response for
Getoperation. - Hash
KvResponse - Response for
hash_kvoperation. - Hash
Response - Response for
hashoperation. - 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
Leaderoperation. - Lease
Client - Client for lease operations.
- Lease
Client Prefix - Lease
Grant Options - Options for
Grantoperation. - Lease
Grant Response - Response for
Grantoperation. - Lease
Keep Alive Response - Response for
KeepAliveoperation. - Lease
Keep Alive Stream - The lease keep alive response stream.
- Lease
Keeper - The lease keep alive handle.
- Lease
Leases Response - Response for
Leasesoperation. - Lease
Revoke Response - Response for
Revokeoperation. - Lease
Status - Lease status.
- Lease
Time ToLive Options - Options for
TimeToLiveoperation. - Lease
Time ToLive Response - Response for
TimeToLiveoperation. - Lock
Client - Client for Lock operations.
- Lock
Options - Options for
Lockoperation. - Lock
Response - Response for
Lockoperation. - Maintenance
Client - Client for maintenance operations.
- Member
- Cluster member.
- Member
AddOptions - Options for
MemberAddoperation. - Member
AddResponse - Response for
MemberAddoperation. - Member
List Response - Response for
MemberListoperation. - Member
Promote Response - Response for
MemberPromoteoperation. - Member
Remove Response - Response for
MemberRemoveoperation. - Member
Update Response - Response for
MemberUpdateoperation. - Move
Leader Response - Response for
MoveLeaderoperation. - Observe
Stream - Response for
Observeoperation. - Permission
- Role access permission.
- Proclaim
Options - Options for
proclaimoperation. - Proclaim
Response - Response for
Proclaimoperation. - PutOptions
- Options for
Putoperation. - PutResponse
- Response for
Putoperation. - Resign
Options - Options for
resignoperation. - Resign
Response - Response for
Resignoperation. - Response
Header - General
etcdresponse 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
snapshotoperation. - Snapshot
Streaming - Response for
snapshotoperation. - Status
Response - Response for
statusoperation. - TlsOptions
tls - Configures TLS settings for endpoints.
- Txn
- Transaction of multiple operations.
- TxnOp
- Transaction operation.
- TxnResponse
- Response for
Txnoperation. - Unlock
Response - Response for
Unlockoperation. - User
AddOptions - Options for
UserAddoperation. - 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
Watchoperation. - Watch
Response - Response for
Watchoperation. - Watch
Stream - The watch response stream.
- Watcher
- The watching handle.
Enums§
- Alarm
Action - Alarm action.
- Alarm
Type - Alarm type.
- Channel
- Represents a channel that can be created by a BalancedChannelBuilder or may be initialized externally and passed into the client.
- Compare
Op - Logical comparison operation.
- Error
- The error type for
etcdclient. - 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.
Traits§
- Balanced
Channel Builder - Creates a balanced channel.