lib/good_job/capsule.rb in good_job-3.21.0 vs lib/good_job/capsule.rb in good_job-3.21.1

- old
+ new

@@ -30,13 +30,13 @@ return unless startable?(force: force) @shared_executor = GoodJob::SharedExecutor.new @notifier = GoodJob::Notifier.new(enable_listening: @configuration.enable_listen_notify, executor: @shared_executor.executor) @poller = GoodJob::Poller.new(poll_interval: @configuration.poll_interval) - @scheduler = GoodJob::Scheduler.from_configuration(@configuration, warm_cache_on_initialize: true) - @notifier.recipients << [@scheduler, :create_thread] - @poller.recipients << [@scheduler, :create_thread] + @multi_scheduler = GoodJob::MultiScheduler.from_configuration(@configuration, warm_cache_on_initialize: true) + @notifier.recipients.push([@multi_scheduler, :create_thread]) + @poller.recipients.push(-> { @multi_scheduler.create_thread({ fanout: true }) }) @cron_manager = GoodJob::CronManager.new(@configuration.cron_entries, start_on_initialize: true, executor: @shared_executor.executor) if @configuration.enable_cron? @startable = false @running = true @@ -50,11 +50,11 @@ # * +N+ will wait at most N seconds and then interrupt active threads. # * +nil+ will trigger a shutdown but not wait for it to complete. # @return [void] def shutdown(timeout: NONE) timeout = @configuration.shutdown_timeout if timeout == NONE - GoodJob._shutdown_all([@shared_executor, @notifier, @poller, @scheduler, @cron_manager].compact, timeout: timeout) + GoodJob._shutdown_all([@shared_executor, @notifier, @poller, @multi_scheduler, @cron_manager].compact, timeout: timeout) @startable = false @running = false end # Shutdown and then start the capsule again. @@ -72,18 +72,18 @@ @running end # @return [Boolean] Whether the capsule has been shutdown. def shutdown? - [@shared_executor, @notifier, @poller, @scheduler, @cron_manager].compact.all?(&:shutdown?) + [@shared_executor, @notifier, @poller, @multi_scheduler, @cron_manager].compact.all?(&:shutdown?) end # Creates an execution thread(s) with the given attributes. # @param job_state [Hash, nil] See {GoodJob::Scheduler#create_thread}. # @return [Boolean, nil] Whether the thread was created. def create_thread(job_state = nil) start if startable? - @scheduler&.create_thread(job_state) + @multi_scheduler&.create_thread(job_state) end private def startable?(force: false)