Sha256: 45c8672f87b5220352962be690c012b76da8cb2c7122edd38ad896a9d0e9150a

Contents?: true

Size: 575 Bytes

Versions: 3

Compression:

Stored size: 575 Bytes

Contents

module Outboxable
  class PollingPublisherWorker
    include Sidekiq::Job
    sidekiq_options queue: 'critical'

    def perform
      Outbox.pending.where(last_attempted_at: [..Time.zone.now, nil]).find_in_batches(batch_size: 100).each do |batch|
        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.
          Outboxable::Worker.perform_async(outbox.id)
          outbox.update(last_attempted_at: 1.minute.from_now, status: :processing)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
outboxable-0.1.7 lib/outboxable/polling_publisher_worker.rb
outboxable-0.1.6 lib/outboxable/polling_publisher_worker.rb
outboxable-0.1.5 lib/outboxable/polling_publisher_worker.rb