Skip to content
API for the coreos/etcd daemon
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib DRY up keys URL building Aug 4, 2013
test Initial commit Aug 3, 2013
.gitignore Initial commit Aug 3, 2013
LICENSE Initial commit Aug 3, 2013
README.md Improved documentation for API usage Aug 4, 2013
etcd-ruby.gemspec Initial commit Aug 3, 2013

README.md

etcd-ruby

API for the coreos/etcd daemon

Description

API for the coreos/etcd daemon

Installation

As usual, you can install it using rubygems.

$ gem install etcd-ruby

Usage

Set an etcd host for connections

Etcd.host = "http://localhost:4001"
List machines/nodes
resp = Etcd.machines
p resp.records
#
Set a key/value
resp = Etcd.set "/foo/bar", "baz"
p resp.record
#
Set a key/value with TTL
resp = Etcd.set "/foo/bar", "baz", ttl: 5
p resp.record
#
Test & Set a key/value

Raises an Etcd::Error if the key does not currently exist or the given prev_value is incorrect

Etcd.set "key-does-not-exist", "baz", prev_value: "nope"
# raises Etcd::Error

Etcd.set "/foo/bar", "baz"

resp = Etcd.set "/foo/bar", "quux", prev_value: "this-value-is-wrong"
# raises Etcd::Error

resp = Etcd.set "/foo/bar", "quux", prev_value: "baz"
p resp.record
#
Get a value
resp = Etcd.get "/foo/bar"
p resp.record
#
List keys
Etcd.set "/foo/foo", "barbar"
Etcd.set "/foo/foo_dir/foo", "barbarbar"

resp = Etcd.list "/foo"
p resp.records
#
Delete key
Etcd.delete "/foo"
Watch for a key/value change/insertion

Watch blocks on a key until it is edited via creation, deletion, or an update. Passing an option timeout: 5 will block for the given time in seconds. If no option is given then it will block forever.

Note, the timeout is only applied to the read_timeout and will stil raise an error if it cannot connect.

resp = Etcd.watch "/foo/message", timeout: 5
p resp.data
You can’t perform that action at this time.