delayed_job
plugin for mutual exclusion.
Define, how many jobs of a certain kind can be enqueued or run at the same time.
Add this line to your application's Gemfile:
gem 'delayed-plugins-mutex', git: 'https://github.com/jan/delayed-plugins-mutex'
Import and run migration:
TODO How to import migration
bundle exec rake db:migrate
Register the plugin like so:
require 'delayed-plugins-mutex'
Delayed::Worker.plugins << Delayed::Plugins::Mutex::Plugin
Delayed::Plugins::Mutex::Plugin.new # Not sure, why this is needed
In a Rails project, this can be done in config/initializers
.
When calling delay, you can now optionally pass new arguments:
Foo.delay(enqueue_mutex: 'some identifier')
Foo.delay(enqueue_mutex: 'some identifier', enqueue_limit: 2)
Foo.delay(perform_mutex: 'some identifier')
Foo.delay(perform_mutex: 'some identifier', perform_limit: 2)
- 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