Class: Sidekiq::Scheduled::Poller

Inherits:
Object
  • Object
show all
Includes:
Actor, Util
Defined in:
lib/sidekiq/scheduled.rb

Overview

The Poller checks Redis every N seconds for jobs in the retry or scheduled set have passed their timestamp and should be enqueued. If so, it just pops the job back onto its original queue so the workers can pick it up like any other job.

Constant Summary collapse

INITIAL_WAIT =
10

Constants included from Util

Util::EXPIRY

Instance Method Summary collapse

Methods included from Actor

included

Methods included from Util

#fire_event, #hostname, #identity, #logger, #process_nonce, #redis, #want_a_hertz_donut?, #watchdog

Methods included from ExceptionHandler

#handle_exception

Constructor Details

#initializePoller

Returns a new instance of Poller.



46
47
48
# File 'lib/sidekiq/scheduled.rb', line 46

def initialize
  @enq = (Sidekiq.options[:scheduled_enq] || Sidekiq::Scheduled::Enq).new
end

Instance Method Details

#poll(first_time = false) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/sidekiq/scheduled.rb', line 50

def poll(first_time=false)
  watchdog('scheduling poller thread died!') do
    initial_wait if first_time

    begin
      @enq.enqueue_jobs
    rescue => ex
      # Most likely a problem with redis networking.
      # Punt and try again at the next interval
      logger.error ex.message
      logger.error ex.backtrace.first
    end

    after(random_poll_interval) { poll }
  end
end