A ruby client for etcd
Add this line to your application's Gemfile:
gem 'etcd'
And then execute:
$ bundle
Or install it yourself as:
$ gem install etcd
client=Etcd.client# this will create a client against etcd server running on localhost on port 4001client=Etcd.client(port: 4002)client=Etcd.client(host: '127.0.0.1',port: 4003)client=Etcd.client(:user_name=>'test',:password=>'pwd')# populates the authentication header for basic HTTP auth with user name and password (useful for proxied connections)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 trueSee Etcd config to setup etcd in SSL mode.
Assuming you have these:
myca.crt- Your internal CAs certificatemy-cert.crt- The "client" certmy-cert.key- The key corresponding tomy-cert.crt
If you were using self signed Certs and have your own CA, You would have set -ca-file in your etcd config also to use myca.crt.
client=Etcd.client(:host=>"your-etcd-host",:port=>443,:use_ssl=>true,:ca_file=>"/pathto/myca.crt",:ssl_cert=>OpenSSL::X509::Certificate.new(File.read("/pathto/my-cert.crt")),:ssl_key=>OpenSSL::PKey::RSA.new("/etc/ssl/my-cert.key",passphrase))#Omit passphrase if not set on your key.client.set('/nodes/n1',value: 1)# with ttlclient.set('/nodes/n2',value: 2,ttl: 4)# sets the ttl to 4 secondsclient.get('/nodes/n2').valueclient.delete('/nodes/n1')client.delete('/nodes/',recursive: true)client.test_and_set('/nodes/n2',value: 2,prevValue: 4)# will set /nodes/n2 's value to 2 only if its previous value was 4client.watch('/nodes/n1')# will wait till the key is changed, and return once its changedclient.get('/nodes')client.machinesclient.leaderMore examples and api details can be found in the wiki
- Ranjib Dey
- Jesse Nelson
- Nilesh Bairagi
- Dr Nic Williams
- [Eric Buth] (https://github.com/buth)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
- If applicable, update the README.md
