Module: HireFire::Environment::DelayedJob::ClassMethods
- Defined in:
- lib/hirefire/environment.rb
Instance Method Summary collapse
-
#hirefire_hire ⇒ nil
This method is an attempt to improve web-request throughput.
Instance Method Details
#hirefire_hire ⇒ nil
This method is an attempt to improve web-request throughput.
A class method for Delayed::Job which first checks if any worker is currently running by checking to see if there are any jobs locked by a worker. If there aren’t any jobs locked by a worker there is a high chance that there aren’t any workers running. If this is the case, then we sure also invoke the ‘self.class.environment.hire’ method
Another check is to see if there is only 1 job (which is the one that was just added before this callback invoked). If this is the case then it’s very likely there aren’t any workers running and we should invoke the ‘self.class.environment.hire’ method to make sure this is the case.
96 97 98 99 100 101 102 |
# File 'lib/hirefire/environment.rb', line 96 def hirefire_hire delayed_job = ::Delayed::Job.new if delayed_job.working == 0 \ or delayed_job.jobs == 1 environment.hire end end |