Skip to content
Ranjib Dey edited this page Jan 14, 2014 · 6 revisions

etcd-ruby is a ruby client for etcd.

Introduction

etcd is partition tolerant, highly available key value store. Few key features of etcd:

  • provides test and set like operations, which can be used to build distributed locks
  • client can watch, and receive notifications for changes in certain keys
  • exposes a file system like api

Usage

For installing and running etcd use the core etcd [documentation] (https://github.com/coreos/etcd)

  • instantiate an etcd client object
client = Etcd.client

this will create an etcd client using localhost and port 4001, for specifying them explicitly

client = Etcd.client(host: '127.0.0.1', port: 4001)
  • create a key named the_doors with value hyacinth house
client.create('/the_doors', value: 'hyacinth house')

note usage of / as prefix, etcd uses / to represent nesting, like file system

  • retrieve the value of a key named /the_doors
client.get('/the_doors').value

Etcd::Client#get method returns a node object. which holds value and other metadata

  • update the value of an existing key
client.update('/the_doors', value: 'people are strange')
  • deleting a key
client.delete('/the_doors')

Awesome, now that you know basic usage of etcd you can go through the main etcd docs for details and use the additional wiki pages to explore how etcd-ruby exposes them as api.

Additional topics

  1. basic operations
  2. advanced operations
  3. using lock module
  4. using leader election module
  5. getting stats

Resources

Feedback

Please feel free to drop any feedback you have.

  • ranjib at linux dot com
Clone this wiki locally