Class: Barbeque::ExecutionPoller

Inherits:
Object
  • Object
show all
Defined in:
lib/barbeque/execution_poller.rb

Instance Method Summary collapse

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

#runObject



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

#stopObject



27
28
29
# File 'lib/barbeque/execution_poller.rb', line 27

def stop
  @stop_requested = true
end