Class: Delayed::JobGroups::Plugin
- Inherits:
-
Plugin
- Object
- Plugin
- Delayed::JobGroups::Plugin
- Defined in:
- lib/delayed/job_groups/plugin.rb
Class Method Summary collapse
-
.callbacks(&block) ⇒ Object
Delayed job callbacks will be registered in a global Delayed::Lifecycle every time a Delayed::Worker is created.
- .job_completed?(job) ⇒ Boolean
- .job_group_cancelled?(job_group_id) ⇒ Boolean
Class Method Details
.callbacks(&block) ⇒ Object
Delayed job callbacks will be registered in a global Delayed::Lifecycle every time a Delayed::Worker is created. This creates problems in test runs that create multiple workers because we register the callbacks multiple times on the same global Lifecycle.
14 15 16 17 18 19 20 21 |
# File 'lib/delayed/job_groups/plugin.rb', line 14 def self.callbacks(&block) registered_lifecycles = Set.new super do |lifecycle| if registered_lifecycles.add?(lifecycle.object_id) block.call(lifecycle) end end end |
.job_completed?(job) ⇒ Boolean
57 58 59 60 61 |
# File 'lib/delayed/job_groups/plugin.rb', line 57 def self.job_completed?(job) # Delayed job will already have marked the job for destruction # if it has completed job.destroyed? end |
.job_group_cancelled?(job_group_id) ⇒ Boolean
53 54 55 |
# File 'lib/delayed/job_groups/plugin.rb', line 53 def self.job_group_cancelled?(job_group_id) !JobGroup.exists?(job_group_id) end |