Class: Sidekiq::ReliableJob::OutboxProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/reliable_job/outbox_processor.rb

Overview

Fetches pending jobs from the Outbox and pushes them to Redis.

Constant Summary collapse

BATCH_SIZE =
1000

Instance Method Summary collapse

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sidekiq/reliable_job/outbox_processor.rb', line 9

def call
  Outbox.transaction do
    Outbox.with_advisory_lock!("sidekiq_reliable_job", transaction: true, timeout_seconds: 0) do
      jobs = fetch_pending_jobs
      return 0 if jobs.empty?

      immediate, scheduled = partition_jobs(jobs)

      process_immediate_jobs(immediate)
      process_scheduled_jobs(scheduled)

      jobs.size
    end
  end
end