Module: Resque::Plugins::ConcurrentRestriction::Worker
- Defined in:
- lib/resque/plugins/concurrent_restriction/resque_worker_extension.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#done_working_with_restriction ⇒ Object
Wrap done_working so we can clear restriction locks after running.
-
#reserve_with_restriction ⇒ Object
Wrap reserve so we can pass the job to done_working to release restriction if necessary.
Class Method Details
.included(receiver) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/resque/plugins/concurrent_restriction/resque_worker_extension.rb', line 7 def self.included(receiver) receiver.class_eval do alias reserve_without_restriction reserve alias reserve reserve_with_restriction alias done_working_without_restriction done_working alias done_working done_working_with_restriction end end |
Instance Method Details
#done_working_with_restriction ⇒ Object
Wrap done_working so we can clear restriction locks after running. We do this here instead of in Job.perform to improve odds of completing successfully by running in the worker parent in case the child segfaults or something. This needs to be a instance method
27 28 29 30 31 32 33 34 |
# File 'lib/resque/plugins/concurrent_restriction/resque_worker_extension.rb', line 27 def done_working_with_restriction begin job_class = @job_in_progress.payload_class job_class.release_restriction(@job_in_progress) if job_class.is_a?(ConcurrentRestriction) ensure return done_working_without_restriction end end |
#reserve_with_restriction ⇒ Object
Wrap reserve so we can pass the job to done_working to release restriction if necessary
18 19 20 21 |
# File 'lib/resque/plugins/concurrent_restriction/resque_worker_extension.rb', line 18 def reserve_with_restriction @job_in_progress = reserve_without_restriction return @job_in_progress end |