Class: Sidekiq::Cron::Poller

Inherits:
Scheduled::Poller
  • Object
show all
Defined in:
lib/sidekiq/cron/poller.rb

Overview

The Poller checks Redis every N seconds for sheduled cron jobs.

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ Poller

Returns a new instance of Poller.



10
11
12
13
14
15
16
17
18
# File 'lib/sidekiq/cron/poller.rb', line 10

def initialize(config = nil)
  if Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('6.5.0')
    super
  else
    # Old version of Sidekiq does not accept a config argument.
    @config = config
    super()
  end
end

Instance Method Details

#enqueueObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sidekiq/cron/poller.rb', line 20

def enqueue
  time = Time.now.utc
  Sidekiq::Cron::Job.all.each do |job|
    enqueue_job(job, time)
  end
rescue => ex
  # Most likely a problem with redis networking.
  # Punt and try again at the next interval.
  Sidekiq.logger.error ex.message
  Sidekiq.logger.error ex.backtrace.first
  handle_exception(ex) if respond_to?(:handle_exception)
end