Class: SidekiqScheduler::Manager

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Manager

Returns a new instance of Manager.



11
12
13
14
15
16
17
# File 'lib/sidekiq-scheduler/manager.rb', line 11

def initialize(config)
  set_current_scheduler_options(config)

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

Instance Method Details

#startObject



23
24
25
# File 'lib/sidekiq-scheduler/manager.rb', line 23

def start
  @scheduler_instance.load_schedule!
end

#stopObject



19
20
21
# File 'lib/sidekiq-scheduler/manager.rb', line 19

def stop
  @scheduler_instance.clear_schedule!
end

#to_hashObject

This method is needed to avoid exposing unnecessary information. Because ActiveSupport’s ‘as_json` traverses instance values to convert the object to a hash unless it responds to `to_hash`.



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

def to_hash
  {
    scheduler: @scheduler_instance.to_hash
  }
end