mirror of
https://github.com/ditkrg/outboxable.git
synced 2026-01-22 22:06:47 +00:00
Adds mechanism to avoid too many retries
This commit is contained in:
parent
fd69f23345
commit
2647c47b53
@ -4,11 +4,13 @@ module Outboxable
|
|||||||
sidekiq_options queue: 'critical'
|
sidekiq_options queue: 'critical'
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
Outbox.pending.find_in_batches(batch_size: 100).each do |batch|
|
Outbox.pending.where(last_attempted_at: [..Time.zone.now, nil]).find_in_batches(batch_size: 100).each do |batch|
|
||||||
batch.each do |outbox|
|
batch.each do |outbox|
|
||||||
|
# This is to prevent a job from being retried too many times. Worst-case scenario is 1 minute delay in jobs.
|
||||||
|
outbox.update(last_attempted_at: 1.minute.from_now)
|
||||||
Outboxable::Worker.perform_async(outbox.id)
|
Outboxable::Worker.perform_async(outbox.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user