Sha256: cfd6f9084fd348503bf14173b90971948b208a65ab4cd71bf93583c767234ba8

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

[![Built on Travis](https://secure.travis-ci.org/ranjib/etcd-ruby.png?branch=master)](http://travis-ci.org/ranjib/etcd-ruby)
# Etcd

A ruby client for [etcd](https://github.com/coreos/etcd)
## Installation

Add this line to your application's Gemfile:

    gem 'etcd'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install etcd

## Usage
### Create a client object
```ruby
client = Etcd.client # this will create a client against etcd server running on localhost on port 4001
client = Etcd.client(:port=>4002)
client = Etcd.client(:host=>'127.0.0.1', :port=>4003)
client = Etcd.client(:host=>'127.0.0.1', :port=>4003, :allow_redirect => false) # wont let you run sensitive commands on non-leader machines, default is true
```
### Set a key
```ruby
client.set('/nodes/n1', 1)
# with ttl
client.set('/nodes/n2', 2, 4)  # sets the ttl to 4 seconds
```
### Get a key
```ruby
client.get('/nodes/n2').value

```
### Delete a key
```ruby
client.delete('/nodes/n1')
```

### Test and set
```ruby
client.test_and_set('/nodes/n2', 2, 4) # will set /nodes/n2 's value to 2 only if its previous value was 4

```

### Watch a key
```ruby
client.watch('/nodes/n1') # will wait till the key is changed, and return once its changed
```

### List sub keys
```ruby
client.get('/nodes')
```

### Get machines in the cluster
```ruby
client.machines
```

### Get leader of the cluster
```ruby
client.leader
```

## Contributors 
* Ranjib Dey
* Jesse Nelson



## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
6. If applicable, update the README.md

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
etcd-0.0.6 README.md
etcd-0.0.5 README.md
etcd-0.0.4 README.md