Class: Barbeque::RetryPoller
- Inherits:
-
Object
- Object
- Barbeque::RetryPoller
- Defined in:
- lib/barbeque/retry_poller.rb
Instance Method Summary collapse
-
#initialize(job_queue) ⇒ RetryPoller
constructor
A new instance of RetryPoller.
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(job_queue) ⇒ RetryPoller
Returns a new instance of RetryPoller.
6 7 8 9 |
# File 'lib/barbeque/retry_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 26 27 28 29 |
# File 'lib/barbeque/retry_poller.rb', line 11 def run Barbeque::JobRetry .joins(:job_execution) .running .merge(Barbeque::JobExecution.where(job_queue: @job_queue)) .find_in_batches do |job_retries| job_retries.shuffle.each do |job_retry| if @stop_requested return end job_retry.with_lock do if job_retry.running? poll(job_retry) end end end end sleep 1 end |
#stop ⇒ Object
31 32 33 |
# File 'lib/barbeque/retry_poller.rb', line 31 def stop @stop_requested = true end |