lib/good_job/configuration.rb in good_job-2.7.4 vs lib/good_job/configuration.rb in good_job-2.8.0
- old
+ new
@@ -16,10 +16,14 @@
DEFAULT_DEVELOPMENT_ASYNC_POLL_INTERVAL = -1
# Default number of threads to use per {Scheduler}
DEFAULT_MAX_CACHE = 10000
# Default number of seconds to preserve jobs for {CLI#cleanup_preserved_jobs} and {GoodJob.cleanup_preserved_jobs}
DEFAULT_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO = 24 * 60 * 60
+ # Default number of jobs to execute between preserved job cleanup runs
+ DEFAULT_CLEANUP_INTERVAL_JOBS = nil
+ # Default number of seconds to wait between preserved job cleanup runs
+ DEFAULT_CLEANUP_INTERVAL_SECONDS = nil
# Default to always wait for jobs to finish for {Adapter#shutdown}
DEFAULT_SHUTDOWN_TIMEOUT = -1
# Default to not running cron
DEFAULT_ENABLE_CRON = false
@@ -175,9 +179,31 @@
options[:before_seconds_ago] ||
rails_config[:cleanup_preserved_jobs_before_seconds_ago] ||
env['GOOD_JOB_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO'] ||
DEFAULT_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO
).to_i
+ end
+
+ # Number of jobs a {Scheduler} will execute before cleaning up preserved jobs.
+ # @return [Integer, nil]
+ def cleanup_interval_jobs
+ value = (
+ rails_config[:cleanup_interval_jobs] ||
+ env['GOOD_JOB_CLEANUP_INTERVAL_JOBS'] ||
+ DEFAULT_CLEANUP_INTERVAL_JOBS
+ )
+ value.present? ? value.to_i : nil
+ end
+
+ # Number of seconds a {Scheduler} will wait before cleaning up preserved jobs.
+ # @return [Integer, nil]
+ def cleanup_interval_seconds
+ value = (
+ rails_config[:cleanup_interval_seconds] ||
+ env['GOOD_JOB_CLEANUP_INTERVAL_SECONDS'] ||
+ DEFAULT_CLEANUP_INTERVAL_SECONDS
+ )
+ value.present? ? value.to_i : nil
end
# Tests whether to daemonize the process.
# @return [Boolean]
def daemonize?