class GoodJob::MultiScheduler
Delegates the interface of a single {Scheduler} to multiple Schedulers.
Attributes
schedulers[R]
@return [Array<Scheduler>] List of the scheduler delegates
Public Class Methods
new(schedulers)
click to toggle source
@param schedulers [Array<Scheduler>]
# File lib/good_job/multi_scheduler.rb 9 def initialize(schedulers) 10 @schedulers = schedulers 11 end
Public Instance Methods
create_thread(state = nil)
click to toggle source
Delegates to {Scheduler#create_thread}. @param state [Hash] @return [Boolean, nil]
# File lib/good_job/multi_scheduler.rb 42 def create_thread(state = nil) 43 results = [] 44 45 if state 46 schedulers.any? do |scheduler| 47 scheduler.create_thread(state).tap { |result| results << result } 48 end 49 else 50 schedulers.each do |scheduler| 51 results << scheduler.create_thread(state) 52 end 53 end 54 55 if results.any? 56 true 57 elsif results.any?(false) 58 false 59 else # rubocop:disable Style/EmptyElse 60 nil 61 end 62 end
restart(timeout: -1)
click to toggle source
Delegates to {Scheduler#restart}. @param timeout [Numeric, nil] @return [void]
# File lib/good_job/multi_scheduler.rb 35 def restart(timeout: -1) 36 GoodJob._shutdown_all(schedulers, :restart, timeout: timeout) 37 end
running?()
click to toggle source
Delegates to {Scheduler#running?}. @return [Boolean, nil]
# File lib/good_job/multi_scheduler.rb 15 def running? 16 schedulers.all?(&:running?) 17 end
shutdown(timeout: -1)
click to toggle source
Delegates to {Scheduler#shutdown}. @param timeout [Numeric, nil] @return [void]
# File lib/good_job/multi_scheduler.rb 28 def shutdown(timeout: -1) 29 GoodJob._shutdown_all(schedulers, timeout: timeout) 30 end
shutdown?()
click to toggle source
Delegates to {Scheduler#shutdown?}. @return [Boolean, nil]
# File lib/good_job/multi_scheduler.rb 21 def shutdown? 22 schedulers.all?(&:shutdown?) 23 end