Struct etcd::Client [] [src]

pub struct Client {
    // some fields omitted
}

API client for etcd. All API calls are made via the client.

Methods

impl Client

fn new(endpoints: &[&str]) -> EtcdResult<Client>

Constructs a new client. endpoints are URLs for the etcd cluster members to the client will make API calls to.

Fails if no endpoints are provided or if any of the endpoints is an invalid URL.

fn with_options(endpoints: &[&str], options: ClientOptions) -> EtcdResult<Client>

Constructs a new client with the given options. endpoints are URLs for the etcd cluster members to the client will make API calls to.

Fails if no endpoints are provided or if any of the endpoints is an invalid URL.

fn compare_and_delete(&self, key: &str, current_value: Option<&str>, current_modified_index: Option<u64>) -> KeySpaceResult

Deletes a key only if the given current value and/or current modified index match.

Fails if the conditions didn't match or if no conditions were given.

fn compare_and_swap(&self, key: &str, value: &str, ttl: Option<u64>, current_value: Option<&str>, current_modified_index: Option<u64>) -> KeySpaceResult

Updates the value of a key only if the given current value and/or current modified index match.

Fails if the conditions didn't match or if no conditions were given.

fn create(&self, key: &str, value: &str, ttl: Option<u64>) -> KeySpaceResult

Creates a new key-value pair with any given time to live in seconds.

Fails if the key already exists.

fn create_dir(&self, key: &str, ttl: Option<u64>) -> KeySpaceResult

Creates a new empty directory at the given key with the given time to live in seconds.

Fails if the key already exists.

fn create_in_order(&self, key: &str, value: &str, ttl: Option<u64>) -> KeySpaceResult

Creates a new key-value pair in the given directory with any given time to live in seconds and a key name guaranteed to be greater than all existing keys in the directory.

Fails if the key already exists and is not a directory.

fn delete(&self, key: &str, recursive: bool) -> KeySpaceResult

Deletes a key-value pair or directory.

If recursive is true and the key is a directory, the directory and all child key-value pairs and directories will be deleted.

Fails if the key is a directory and recursive is false.

fn delete_dir(&self, key: &str) -> KeySpaceResult

Deletes an empty directory or a key-value pair at the given key.

Fails if the directory is not empty.

fn get(&self, key: &str, sort: bool, recursive: bool, strong_consistency: bool) -> KeySpaceResult

Gets the value of a key.

If the key is a directory, sort will determine whether the contents of the directory are returned in a sorted order.

If the key is a directory and recursive is true, the contents of child directories will be returned as well.

If strong_consistency is true, the etcd node serving the response will synchronize with the quorum before returning the value. This is slower but avoids possibly stale data from being returned.

fn leader_stats(&self) -> EtcdResult<LeaderStats>

Returns statistics about the leader member of a cluster.

Fails if JSON decoding fails, which suggests a bug in our schema.

fn self_stats(&self) -> Vec<EtcdResult<SelfStats>>

Returns statistics about each cluster member the client was initialized with.

Fails if JSON decoding fails, which suggests a bug in our schema.

fn set(&self, key: &str, value: &str, ttl: Option<u64>) -> KeySpaceResult

Sets the key to the given value with the given time to live in seconds. Any previous value and TTL will be replaced.

Fails if the key is a directory.

fn set_dir(&self, key: &str, ttl: Option<u64>) -> KeySpaceResult

Sets the key to an empty directory with the given time to live in seconds. An existing key-value will be replaced, but an existing directory will not.

Fails if the key is an existing directory.

fn store_stats(&self) -> Vec<EtcdResult<StoreStats>>

Returns statistics about operations handled by each etcd member the client was initialized with.

Fails if JSON decoding fails, which suggests a bug in our schema.

fn update(&self, key: &str, value: &str, ttl: Option<u64>) -> KeySpaceResult

Updates the given key to the given value and time to live in seconds.

Fails if the key does not exist.

fn update_dir(&self, key: &str, ttl: Option<u64>) -> KeySpaceResult

Updates the given key to a directory with the given time to live in seconds. If the directory already existed, only the TTL is updated. If the key was a key-value pair, its value is removed and its TTL is updated.

Fails if the key does not exist.

fn versions(&self) -> Vec<EtcdResult<VersionInfo>>

Returns version information from each etcd cluster member the client was initialized with.

fn watch(&self, key: &str, index: Option<u64>, recursive: bool) -> KeySpaceResult

Watches etcd for changes to the given key (including all child keys if recursive is true,) and returns the new value as soon as a change takes place.

The watch will return the first change indexed with index or greater, if specified, allowing you to watch for changes that happened in the past.

Fails if a supplied index value is too old and has been flushed out of etcd's internal store of the most recent change events. In this case, the key should be queried for its latest "modified index" value and that should be used as the new index on a subsequent watch.

Trait Implementations

impl Default for Client

fn default() -> Self

Derived Implementations

impl Debug for Client

fn fmt(&self, __arg_0: &mut Formatter) -> Result