You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It requires resque 1.25 and works with ruby 2.0 and later.
It removes the dependency on Resque::Helpers, which is deprecated for resque 2.0.
Install
Add the gem to your Gemfile:
gem'resque-unique_in_queue'
Usage
resque-unique_in_queue utilizes 3 class instance variables that can be set
in your Jobs, in addition to the standard @queue. Here they are, with their
default values:
By default, lock_after_execution_period is 0 and enqueued? becomes false as soon as the job
is being worked on.
The lock_after_execution_period setting can be used to delay when the unique job key is deleted
(i.e. when enqueued? becomes false). For example, if you have a long-running unique job that
takes around 10 seconds, and you don't want to requeue another job until you are sure it is done,
you could set lock_after_execution_period = 20. Or if you never want to run a long running
job more than once per minute, set lock_after_execution_period = 60.
classUpdateCatincludeResque::Plugins::UniqueInQueue@queue=:cats@lock_after_execution_period=20defself.perform(cat_id)# do somethingendend
Oops, I have stale Queue Time uniqueness keys...
Preventing jobs with matching signatures from being queued, and they never get
dequeued because there is no actual corresponding job to dequeue.
How to deal?
Option: Rampage
# Delete *all* queued jobs in the queue, and# delete *all* unqueness keys for the queue.Redis.remove_queue('queue_name')
Option: Butterfly
# Delete *no* queued jobs at all, and# delete *all* unqueness keys for the queue (might then allow duplicates).Resque::UniqueInQueue::Queue.cleanup('queue_name')
Create your feature branch (git checkout -b my-new-feature)
Commit your changes (git commit -am 'Added some feature')
Push to the branch (git push origin my-new-feature)
Create new Pull Request
Code of Conduct
Everyone interacting in the Resque::Plugins::UniqueInQueue project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Versioning
This library aims to adhere to Semantic Versioning 2.0.0.
Violations of this scheme should be reported as bugs. Specifically,
if a minor or patch version is released that breaks backward
compatibility, a new version should be immediately released that
restores compatibility. Breaking changes to the public API will
only be introduced with new major versions.
As a result of this policy, you can (and should) specify a
dependency on this gem using the Pessimistic Version Constraint with two digits of precision.