lib/good_job/configuration.rb in good_job-1.4.1 vs lib/good_job/configuration.rb in good_job-1.5.0
- old
+ new
@@ -43,10 +43,12 @@
# Value to use if none was specified in the configuration.
# @return [Symbol]
def execution_mode(default: :external)
if options[:execution_mode]
options[:execution_mode]
+ elsif rails_config[:execution_mode]
+ rails_config[:execution_mode]
elsif env['GOOD_JOB_EXECUTION_MODE'].present?
env['GOOD_JOB_EXECUTION_MODE'].to_sym
else
default
end
@@ -70,10 +72,11 @@
# individual schedulers.
# @return [Integer]
def max_threads
(
options[:max_threads] ||
+ rails_config[:max_threads] ||
env['GOOD_JOB_MAX_THREADS'] ||
env['RAILS_MAX_THREADS'] ||
DEFAULT_MAX_THREADS
).to_i
end
@@ -83,10 +86,11 @@
# {file:README.md#optimize-queues-threads-and-processes} for more details
# on the format of this string.
# @return [String]
def queue_string
options[:queues] ||
+ rails_config[:queues] ||
env['GOOD_JOB_QUEUES'] ||
'*'
end
# The number of seconds between polls for jobs. GoodJob will execute jobs
@@ -94,10 +98,11 @@
# poll (using this interval) for new queued jobs to execute.
# @return [Integer]
def poll_interval
(
options[:poll_interval] ||
+ rails_config[:poll_interval] ||
env['GOOD_JOB_POLL_INTERVAL'] ||
DEFAULT_POLL_INTERVAL
).to_i
end
@@ -105,11 +110,18 @@
# This configuration is only used when {GoodJob.preserve_job_records} is +true+.
# @return [Boolean]
def cleanup_preserved_jobs_before_seconds_ago
(
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
+
+ private
+
+ def rails_config
+ Rails.application.config.good_job
end
end
end