RailsIron
Process background tasks for Rails applications using IronWorker. The aim is to provide a Sidekiq compatible interface.
Installation
$ gem install rails_iron
Usage
Add a worker into your app/workers
folder:
# app/workers/my_hard_worker.rb
require "rails_iron"
class MyHardWorker
include RailsIron::Worker
def perform
10.times { "hard work" }
end
end
The require "rails_iron"
is necessary to boot your Iron.io worker.
Now go ahead and create a background task from within your application:
MyHardWorker.perform_async
You may also supply arguments to the worker:
# app/workers/my_hard_worker.rb
require "rails_iron"
class MyHardWorker
include RailsIron::Worker
def perform(work)
puts "hard #{work}"
end
end
MyHardWorker.perform_async("rock")
Todo
This library isn't finished yet, the following is still missing:
- a Rake task for building and uploading the worker
- documentation on how to supply ENV variables
- a mechanism to catch Rails database timeouts during boot time
Testing
To run the tests:
$ rspec
Contributing
- Fork it.
- Create a branch (
git checkout -b my_feature
) - Commit your changes (
git commit -am "Added Feature"
) - Push to the branch (
git push origin my_feature
) - Open a Pull Request
- Enjoy a refreshing Diet Coke and wait
License
Please see LICENSE for licensing details.
Author
Harm-Jan Blok, http://sudoit.nl