Class: SidekiqScheduler::Manager

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Util
Defined in:
lib/sidekiq-scheduler/manager.rb

Overview

The delayed job router in the system. This manages the scheduled jobs pushed messages from Redis onto the work queues

Constant Summary collapse

DEFAULT_SCHEDULER_OPTIONS =
{
  enabled: true,
  dynamic: false,
  dynamic_every: '5s',
  schedule: {}
}

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Manager

Returns a new instance of Manager.


24
25
26
27
28
29
30
# File 'lib/sidekiq-scheduler/manager.rb', line 24

def initialize(options)
  scheduler_options = load_scheduler_options(options)

  @scheduler_instance = SidekiqScheduler::Scheduler.new(scheduler_options)
  SidekiqScheduler::Scheduler.instance = @scheduler_instance
  Sidekiq.schedule = scheduler_options[:schedule] if @scheduler_instance.enabled
end

Instance Method Details

#resetObject


40
41
42
# File 'lib/sidekiq-scheduler/manager.rb', line 40

def reset
  clear_scheduled_work
end

#startObject


36
37
38
# File 'lib/sidekiq-scheduler/manager.rb', line 36

def start
  @scheduler_instance.load_schedule!
end

#stopObject


32
33
34
# File 'lib/sidekiq-scheduler/manager.rb', line 32

def stop
  @scheduler_instance.clear_schedule!
end