Sha256: 2058889996a6e9606f15902093918d489faebf34ff8131fd0279720f2500091d

Contents?: true

Size: 555 Bytes

Versions: 1

Compression:

Stored size: 555 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. 
          outbox.update(last_attempted_at: 1.minute.from_now)
          Outboxable::Worker.perform_async(outbox.id)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outboxable-0.1.3 lib/outboxable/polling_publisher_worker.rb