Syncrony is a set of distributed systems primitives built with Celluloid and Etcd.
Add this line to your application's Gemfile:
gem 'syncrony'
And then execute:
$ bundle
Or install it yourself as:
$ gem install syncrony
The Observer is a simple primitive that allows you to execute a block every time a key changes in etcd. Upon calling Observer.run callback will be executed immediately and every time thereafter they key changes.
require 'syncrony'
require 'etcd'
client = Etcd::Client.new
client.connect
obs = Syncrony::Observer.new(client, 'test_key')
obs.run do |value, key, info|
puts value, key, info
end
Election is a higher level primitive that implements basic leader election. The initial call to Election.run will block until we become the leader, at which point it will then run in the background. We can step down or cancel leader election by running Election.cancel.
require 'syncrony'
election = Syncrony::Election.new(:path => 'test_key')
election.run
- 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