Robinhood is a DSL for constructing iteration-based synchronous processes (aka can't be run as jobs) in a distributed manner.
In other words: Robs responsibilities from richer processes and gives them to the poor.
It leverages celluloid actors for each process and uses Redis as a locking mechanism to ensure the process is run in a single server.
Install the gem:
$ gem install robinhood
Define Robinhood in a file:
require 'robinhood'
require 'your-app'
Robinhood.define do
redis{ Redis.new(:host => "10.0.1.1", :port => 6380) }
process :assigner, throttle: 10 do
UserAssigner.process!
end
process :sweeper, throttle: false, timeout: 20 do
Sweeper.sweep!
end
end
Robinhood.run
Each time a process finishes its execution, the lock is released so any other server (or system process) can execute it again. This ensures it will be executed in a synchronous manner (one after the other). It also garantees the executions will be distributed across the processes (or servers) so if a server goes down, the load will be distributed evenly across the rest of them.
You can also set a timeout (in case a process hangs for some reason) and a throttling mechanism (so a process can't be re-scheduled before this time has passed).
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)