Class: Barbeque::ExecutionPoller
- Inherits:
-
Object
- Object
- Barbeque::ExecutionPoller
- Defined in:
- lib/barbeque/execution_poller.rb
Instance Method Summary collapse
-
#initialize(job_queue) ⇒ ExecutionPoller
constructor
A new instance of ExecutionPoller.
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(job_queue) ⇒ ExecutionPoller
Returns a new instance of ExecutionPoller.
6 7 8 9 |
# File 'lib/barbeque/execution_poller.rb', line 6 def initialize(job_queue) @job_queue = job_queue @stop_requested = false end |
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/barbeque/execution_poller.rb', line 11 def run @job_queue.job_executions.running.find_in_batches do |job_executions| job_executions.shuffle.each do |job_execution| if @stop_requested return end job_execution.with_lock do if job_execution.running? poll(job_execution) end end end end sleep 1 end |
#stop ⇒ Object
27 28 29 |
# File 'lib/barbeque/execution_poller.rb', line 27 def stop @stop_requested = true end |