lib/good_job.rb in good_job-3.28.2 vs lib/good_job.rb in good_job-3.29.3
- old
+ new
@@ -17,10 +17,11 @@
require_relative "good_job/overridable_connection"
require_relative "good_job/bulk"
require_relative "good_job/callable"
require_relative "good_job/capsule"
+require_relative "good_job/capsule_tracker"
require_relative "good_job/cleanup_tracker"
require_relative "good_job/cli"
require_relative "good_job/configuration"
require_relative "good_job/cron_manager"
require_relative "good_job/current_thread"
@@ -167,23 +168,31 @@
_shutdown_all(Capsule.instances, :restart, timeout: timeout)
end
# Sends +#shutdown+ or +#restart+ to executable objects ({GoodJob::Notifier}, {GoodJob::Poller}, {GoodJob::Scheduler}, {GoodJob::MultiScheduler}, {GoodJob::CronManager})
- # @param executables [Array<Notifier, Poller, Scheduler, MultiScheduler, CronManager>] Objects to shut down.
+ # @param executables [Array<Notifier, Poller, Scheduler, MultiScheduler, CronManager, SharedExecutor>] Objects to shut down.
# @param method_name [:symbol] Method to call, e.g. +:shutdown+ or +:restart+.
# @param timeout [nil,Numeric]
+ # @param after [Array<Notifier, Poller, Scheduler, MultiScheduler, CronManager, SharedExecutor>] Objects to shut down after initial executables shut down.
# @return [void]
- def self._shutdown_all(executables, method_name = :shutdown, timeout: -1)
+ def self._shutdown_all(executables, method_name = :shutdown, timeout: -1, after: [])
if timeout.is_a?(Numeric) && timeout.positive?
executables.each { |executable| executable.send(method_name, timeout: nil) }
stop_at = Time.current + timeout
executables.each { |executable| executable.send(method_name, timeout: [stop_at - Time.current, 0].max) }
else
executables.each { |executable| executable.send(method_name, timeout: timeout) }
end
+ return unless after.any? && !timeout.nil?
+
+ if stop_at
+ after.each { |executable| executable.shutdown(timeout: [stop_at - Time.current, 0].max) }
+ else
+ after.each { |executable| executable.shutdown(timeout: timeout) }
+ end
end
# Destroys preserved job and batch records.
# By default, GoodJob destroys job records when the job is performed and this
# method is not necessary. However, when `GoodJob.preserve_job_records = true`,
@@ -276,10 +285,10 @@
# For use in tests/CI to validate GoodJob is up-to-date.
# @return [Boolean]
def self.migrated?
# Always update with the most recent migration check
GoodJob::Execution.reset_column_information
- GoodJob::Execution.candidate_lookup_index_migrated?
+ GoodJob::Execution.process_lock_migrated?
end
ActiveSupport.run_load_hooks(:good_job, self)
end