lib/good_job/configuration.rb in good_job-1.2.5 vs lib/good_job/configuration.rb in good_job-1.2.6
- old
+ new
@@ -3,10 +3,17 @@
# +GoodJob::Configuration+ provides normalized configuration information to
# the rest of GoodJob. It combines environment information with explicitly
# set options to get the final values for each option.
#
class Configuration
+ # Default number of threads to use per {Scheduler}
+ DEFAULT_MAX_THREADS = 5
+ # Default number of seconds between polls for jobs
+ DEFAULT_POLL_INTERVAL = 1
+ # Default number of seconds to preserve jobs for {CLI#cleanup_preserved_jobs}
+ DEFAULT_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO = 24 * 60 * 60
+
# @!attribute [r] options
# The options that were explicitly set when initializing +Configuration+.
# @return [Hash]
#
# @!attribute [r] env
@@ -67,11 +74,11 @@
def max_threads
(
options[:max_threads] ||
env['GOOD_JOB_MAX_THREADS'] ||
env['RAILS_MAX_THREADS'] ||
- ActiveRecord::Base.connection_pool.size
+ DEFAULT_MAX_THREADS
).to_i
end
# Describes which queues to execute jobs from and how those queues should
# be grouped into {Scheduler} instances. See
@@ -90,18 +97,18 @@
# @return [Integer]
def poll_interval
(
options[:poll_interval] ||
env['GOOD_JOB_POLL_INTERVAL'] ||
- 1
+ DEFAULT_POLL_INTERVAL
).to_i
end
def cleanup_preserved_jobs_before_seconds_ago
(
options[:before_seconds_ago] ||
env['GOOD_JOB_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO'] ||
- 24 * 60 * 60
+ DEFAULT_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO
).to_i
end
end
end