Delayed Job Unique
Delayed Job Unique is a Ruby gem that provides an extension to
delayed_job_active_record for handling unique jobs in the queue.
$ bundle add delayed_job_unique
Or add the following line to your application's Gemfile:
And then execute:
$ bundle install
The gem provides a
Delayed::Job::enqueue_once class method which will use the
unique_key of your job to check for other not failed jobs enqueued under the same key.
This provides a simple yet flexible mechanism to finely control the concurrency on each Job class.
If the job was already enqueued it will return
false, otherwise it will return the enqueued job instance.
class MyUniqueJob def perform # Your job logic here end def unique_key # Return a unique key for the job (String) end end # Enqueue the job only if it's not already in the queue if Delayed::Job.enqueue_once(MyUniqueJob.new) # job enqueued else # job was already enqueued end
git clone https://github.com/sinaptia/delayed_job_unique.git cd delayed_job_uniq bundle install
- Fork it
- Create your feature branch (
git checkout -b feature/my-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin feature/my-feature)
- Create a new Pull Request