API
Etcd.connect — Function.connect(host="localhost", port=2379, version="v2")Creates an Etcd.Client which can then be used for making requests to an etcd cluster.
Base.get — Method.get(cli, key, sort=false, recursive=false) -> DictFetches the value for the specified key from the etcd cluster. See the etcd API for more details.
Etcd.cad — Method.cad(cli, key; prev_value=nothing, prev_index=-1) -> DictPerforms an atomic compare-and-delete on the key in the etcd cluster. See the etcd API for more details.
Etcd.cas — Method.cas(cli, key, value; prev_value=nothing, prev_index=-1, ttl=-1) -> DictPerforms an atomic compare-and-swap with the key and value on the etcd cluster. See the etcd API for more details.
Etcd.create — Method.create(cli, key, value; ttl=-1) -> DictCreates a new key/value pair on the etcd cluster, asserting that the key does not already exist.
Etcd.createdir — Method.createdir(cli, key; ttl=-1) -> DictCreates a new directory on the etcd cluster, asserting that the directory does not already exist.
Etcd.delete — Method.delete(cli, key) -> DictRemoves the key from the etcd cluster.
Etcd.deletedir — Method.deletedir(cli, key; recursive=false) -> DictRemoves the directory from the etcd cluster.
Etcd.exists — Method.exists(cli, key) -> BoolReturns whether the key exists in the etcd cluster.
Etcd.set — Method.set(cli, key, value; ttl=-1, ordered=false) -> DictSets the value for the specified key in the etcd cluster. See the etcd API for more details.
Etcd.setdir — Method.setdir(cli, key; ttl=-1) -> DictCreates a directory with the specified key on the etcd cluster.
Reference: https://github.com/coreos/etcd/blob/master/Documentation/v2/api.md#creating-directories
Etcd.update — Method.update(cli, key, value; ttl=-1) -> DictUpdates an existing key with a new value on the etcd cluster, asserting that the key must already exist.
Etcd.updatedir — Method.updatedir(cli, key; ttl=-1) -> DictUpdates the name of a direcotry on the etcd cluster, asserting that the directory already exists.
Etcd.watch — Method.watch(f, cli, key; wait_index=-1, recursive=false)Creates an asynchronous Task which watches the key on the etcd cluster and runs function f on the response. See the etcd API for more details.
Etcd.watchloop — Function.watchloop(f, cli, key, [p]; wait_index=-1, recursive=false)Creates an asynchrous Task which continously watches the key on the etcd cluster and runs function f on the response. The predicate function p represents a termination condition to exit the loop. See the etcd API for more details.
Etcd.machines — Method.machines(cli) -> ArrayReturns an array of machines (socket addresses) in the cluster.
Etcd.stats — Method.stats(cli, stats_type) -> DictFetches any stats from the cluster (stats_type may be "store", "self" or "leader") See the etcd API for more details.
Etcd.leader — Method.leader(cli) -> DictFetchers the stats for the leader of the etcd cluster. See the etcd API for more details.
Etcd.members — Method.members(cli) -> DictReturns a dict (id, member) of members in the etcd cluster. See the etcd API for more details.
Etcd.request — Function.request(f, uri, opts; n=5, max_delay=10.0)Executes the HTTP request f with the given uri and opts and returns the response body. JSON responses are parsed with Requests.json otherwise a String is returned. For failed HTTP or etcd requests an HTTPError or EtcdError is thrown respectively.
Arguments
f::Function: a validRequestsmethod (e.g.,Requests.get)uri::String: the HTTP uriopts::Dict: a set of options to be passed tofwith the keywordqueryn=5: the number of retry attempts for the requestmax_delay=10.0: delay in seconds between each retry attempt
Throws
HTTPError: when the HTTP response has a status code >= 400EtcdError: when the HTTP response body contains "errorCode" which signifies an etcd error
Returns
Dict: for most etcd response (the parsed json HTTP response body)Array: some etcd responses return a list vs dict when parse the json HTTP response bodyString: all non-json response bodies
Etcd.HTTPError — Type.HTTPError <: ExceptionWraps a Requests.Response when the response status is >= 400.
Etcd.EtcdError — Type.EtcdError <: ExceptionWraps an etcd response Dict when the response contains an "errorCode".
Etcd.install — Function.install(force=true)Downloads and installs a local etcd server (mostly for testing).
Etcd.start — Function.start(timeout=-1) -> FutureStarts up the local etcd server (mostly for testing). The timeout specifies a number of seconds to run the server for (using timeout or gtimeout).