API

API

Etcd.connectFunction.
connect(host="localhost", port=2379, version="v2")

Creates an Etcd.Client which can then be used for making requests to an etcd cluster.

source
Base.getMethod.
get(cli, key, sort=false, recursive=false) -> Dict

Fetches the value for the specified key from the etcd cluster. See the etcd API for more details.

source
Etcd.cadMethod.
cad(cli, key; prev_value=nothing, prev_index=-1) -> Dict

Performs an atomic compare-and-delete on the key in the etcd cluster. See the etcd API for more details.

source
Etcd.casMethod.
cas(cli, key, value; prev_value=nothing, prev_index=-1, ttl=-1) -> Dict

Performs an atomic compare-and-swap with the key and value on the etcd cluster. See the etcd API for more details.

source
Etcd.createMethod.
create(cli, key, value; ttl=-1) -> Dict

Creates a new key/value pair on the etcd cluster, asserting that the key does not already exist.

source
Etcd.createdirMethod.
createdir(cli, key; ttl=-1) -> Dict

Creates a new directory on the etcd cluster, asserting that the directory does not already exist.

source
Etcd.deleteMethod.
delete(cli, key) -> Dict

Removes the key from the etcd cluster.

source
Etcd.deletedirMethod.
deletedir(cli, key; recursive=false) -> Dict

Removes the directory from the etcd cluster.

source
Etcd.existsMethod.
exists(cli, key) -> Bool

Returns whether the key exists in the etcd cluster.

source
Etcd.setMethod.
set(cli, key, value; ttl=-1, ordered=false) -> Dict

Sets the value for the specified key in the etcd cluster. See the etcd API for more details.

source
Etcd.setdirMethod.
setdir(cli, key; ttl=-1) -> Dict

Creates a directory with the specified key on the etcd cluster.

Reference: https://github.com/coreos/etcd/blob/master/Documentation/v2/api.md#creating-directories

source
Etcd.updateMethod.
update(cli, key, value; ttl=-1) -> Dict

Updates an existing key with a new value on the etcd cluster, asserting that the key must already exist.

source
Etcd.updatedirMethod.
updatedir(cli, key; ttl=-1) -> Dict

Updates the name of a direcotry on the etcd cluster, asserting that the directory already exists.

source
Etcd.watchMethod.
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.

source
Etcd.watchloopFunction.
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.

source
Etcd.machinesMethod.
machines(cli) -> Array

Returns an array of machines (socket addresses) in the cluster.

source
Etcd.statsMethod.
stats(cli, stats_type) -> Dict

Fetches any stats from the cluster (stats_type may be "store", "self" or "leader") See the etcd API for more details.

source
Etcd.leaderMethod.
leader(cli) -> Dict

Fetchers the stats for the leader of the etcd cluster. See the etcd API for more details.

source
Etcd.membersMethod.
members(cli) -> Dict

Returns a dict (id, member) of members in the etcd cluster. See the etcd API for more details.

source
Etcd.requestFunction.
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 valid Requests method (e.g., Requests.get)

  • uri::String: the HTTP uri

  • opts::Dict: a set of options to be passed to f with the keyword query

  • n=5: the number of retry attempts for the request

  • max_delay=10.0: delay in seconds between each retry attempt

Throws

  • HTTPError: when the HTTP response has a status code >= 400

  • EtcdError: 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 body

  • String: all non-json response bodies

source
Etcd.HTTPErrorType.
HTTPError <: Exception

Wraps a Requests.Response when the response status is >= 400.

source
Etcd.EtcdErrorType.
EtcdError <: Exception

Wraps an etcd response Dict when the response contains an "errorCode".

source
Etcd.installFunction.
install(force=true)

Downloads and installs a local etcd server (mostly for testing).

source
Etcd.startFunction.
start(timeout=-1) -> Future

Starts up the local etcd server (mostly for testing). The timeout specifies a number of seconds to run the server for (using timeout or gtimeout).

source