lib/good_job/configuration.rb in good_job-4.0.1 vs lib/good_job/configuration.rb in good_job-4.0.2
- old
+ new
@@ -228,22 +228,22 @@
# processes to ensure a thread can retrieve an eligible and unlocked job.
# @return [Integer, nil]
def queue_select_limit
(
options[:queue_select_limit] ||
- rails_config[:queue_select_limit] ||
- env['GOOD_JOB_QUEUE_SELECT_LIMIT']
+ rails_config[:queue_select_limit] ||
+ env['GOOD_JOB_QUEUE_SELECT_LIMIT']
)&.to_i
end
# The number of seconds that a good_job process will idle with out running a job before exiting
# @return [Integer, nil] Number of seconds or nil means do not idle out.
def idle_timeout
(
options[:idle_timeout] ||
- rails_config[:idle_timeout] ||
- env['GOOD_JOB_IDLE_TIMEOUT']
+ rails_config[:idle_timeout] ||
+ env['GOOD_JOB_IDLE_TIMEOUT']
)&.to_i || nil
end
# Whether to automatically destroy discarded jobs that have been preserved.
# @return [Boolean]
@@ -267,72 +267,41 @@
# Number of jobs a {Scheduler} will execute before automatically cleaning up preserved jobs.
# Positive values will clean up after that many jobs have run, false or 0 will disable, and -1 will clean up after every job.
# @return [Integer, Boolean, nil]
def cleanup_interval_jobs
- if rails_config.key?(:cleanup_interval_jobs)
- value = rails_config[:cleanup_interval_jobs]
- if value.nil?
- GoodJob.deprecator.warn(
- %(Setting `config.good_job.cleanup_interval_jobs` to `nil` will no longer disable count-based cleanups in GoodJob v4. Set to `false` to disable, or `-1` to run every time.)
- )
- value = false
- elsif value == 0 # rubocop:disable Style/NumericPredicate
- GoodJob.deprecator.warn(
- %(Setting `config.good_job.cleanup_interval_jobs` to `0` will disable count-based cleanups in GoodJob v4. Set to `false` to disable, or `-1` to run every time.)
- )
- value = -1
- end
- elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_JOBS')
- value = env['GOOD_JOB_CLEANUP_INTERVAL_JOBS']
- if value.blank?
- GoodJob.deprecator.warn(
- %(Setting `GOOD_JOB_CLEANUP_INTERVAL_JOBS` to `""` will no longer disable count-based cleanups in GoodJob v4. Set to `0` to disable, or `-1` to run every time.)
- )
- value = false
- elsif value == '0'
- value = false
- end
+ value = if rails_config.key?(:cleanup_interval_jobs)
+ rails_config[:cleanup_interval_jobs]
+ elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_JOBS')
+ env['GOOD_JOB_CLEANUP_INTERVAL_JOBS']
+ end
+
+ if value.in? [nil, "", true]
+ DEFAULT_CLEANUP_INTERVAL_JOBS
+ elsif value.in? [0, "0", false, "false"]
+ false
else
- value = DEFAULT_CLEANUP_INTERVAL_JOBS
+ value ? value.to_i : false
end
-
- value ? value.to_i : false
end
# Number of seconds a {Scheduler} will wait before automatically cleaning up preserved jobs.
# Positive values will clean up after that many jobs have run, false or 0 will disable, and -1 will clean up after every job.
- # @return [Integer, nil]
+ # @return [Integer, Boolean, nil]
def cleanup_interval_seconds
- if rails_config.key?(:cleanup_interval_seconds)
- value = rails_config[:cleanup_interval_seconds]
+ value = if rails_config.key?(:cleanup_interval_seconds)
+ rails_config[:cleanup_interval_seconds]
+ elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_SECONDS')
+ env['GOOD_JOB_CLEANUP_INTERVAL_SECONDS']
+ end
- if value.nil?
- GoodJob.deprecator.warn(
- %(Setting `config.good_job.cleanup_interval_seconds` to `nil` will no longer disable time-based cleanups in GoodJob v4. Set to `false` to disable, or `-1` to run every time.)
- )
- value = false
- elsif value == 0 # rubocop:disable Style/NumericPredicate
- GoodJob.deprecator.warn(
- %(Setting `config.good_job.cleanup_interval_seconds` to `0` will disable time-based cleanups in GoodJob v4. Set to `false` to disable, or `-1` to run every time.)
- )
- value = -1
- end
- elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_SECONDS')
- value = env['GOOD_JOB_CLEANUP_INTERVAL_SECONDS']
- if value.blank?
- GoodJob.deprecator.warn(
- %(Setting `GOOD_JOB_CLEANUP_INTERVAL_SECONDS` to `""` will no longer disable time-based cleanups in GoodJob v4. Set to `0` to disable, or `-1` to run every time.)
- )
- value = false
- elsif value == '0'
- value = false
- end
+ if value.nil? || value == "" || value == true
+ DEFAULT_CLEANUP_INTERVAL_SECONDS
+ elsif value.in? [0, "0", false, "false"]
+ false
else
- value = DEFAULT_CLEANUP_INTERVAL_SECONDS
+ value ? value.to_i : false
end
-
- value ? value.to_i : false
end
# Tests whether to daemonize the process.
# @return [Boolean]
def daemonize?