Class: TjScaleRuby::Configuration
- Inherits:
-
Object
- Object
- TjScaleRuby::Configuration
- Defined in:
- lib/tj_scale_ruby/configuration.rb
Overview
Reads Heroku / scaling settings from environment variables.
Constant Summary collapse
- DEFAULT_INTERVAL_SECONDS =
20- JOB_BACKENDS =
%w[auto delayed_job sidekiq].freeze
Instance Attribute Summary collapse
-
#interval_seconds ⇒ Object
readonly
Returns the value of attribute interval_seconds.
-
#job_backend ⇒ Object
readonly
Returns the value of attribute job_backend.
-
#max_priority ⇒ Object
readonly
Returns the value of attribute max_priority.
-
#min_priority ⇒ Object
readonly
Returns the value of attribute min_priority.
-
#monitor_process ⇒ Object
readonly
Returns the value of attribute monitor_process.
-
#sidekiq_queues ⇒ Object
readonly
Returns the value of attribute sidekiq_queues.
Instance Method Summary collapse
-
#initialize(env = ENV) ⇒ Configuration
constructor
A new instance of Configuration.
-
#target_app ⇒ Object
Heroku app name the scaler should act on (defaults to HEROKU_APP_NAME when unset).
-
#target_process ⇒ Object
Process type to scale on that app: “web” or “worker”.
Constructor Details
#initialize(env = ENV) ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/tj_scale_ruby/configuration.rb', line 12 def initialize(env = ENV) @monitor_process = normalize_process(env["TJ_SCALE_MONITOR_PROCESS"]) || "worker" @job_backend = normalize_job_backend(env["TJ_SCALE_JOB_BACKEND"]) @sidekiq_queues = parse_list(env["TJ_SCALE_SIDEKIQ_QUEUES"]) @interval_seconds = parse_positive_int(env["TJ_SCALE_INTERVAL_SECONDS"], DEFAULT_INTERVAL_SECONDS) @target_app = nonempty_string(env["TJ_SCALE_TARGET_APP"]) @heroku_app_name = nonempty_string(env["HEROKU_APP_NAME"]) @target_process = normalize_process(env["TJ_SCALE_TARGET_PROCESS"]) || @monitor_process @min_priority = env["TJ_MIN_PRIORITY"].to_i @max_priority = env["TJ_MAX_PRIORITY"].to_i end |
Instance Attribute Details
#interval_seconds ⇒ Object (readonly)
Returns the value of attribute interval_seconds.
9 10 11 |
# File 'lib/tj_scale_ruby/configuration.rb', line 9 def interval_seconds @interval_seconds end |
#job_backend ⇒ Object (readonly)
Returns the value of attribute job_backend.
9 10 11 |
# File 'lib/tj_scale_ruby/configuration.rb', line 9 def job_backend @job_backend end |
#max_priority ⇒ Object (readonly)
Returns the value of attribute max_priority.
9 10 11 |
# File 'lib/tj_scale_ruby/configuration.rb', line 9 def max_priority @max_priority end |
#min_priority ⇒ Object (readonly)
Returns the value of attribute min_priority.
9 10 11 |
# File 'lib/tj_scale_ruby/configuration.rb', line 9 def min_priority @min_priority end |
#monitor_process ⇒ Object (readonly)
Returns the value of attribute monitor_process.
9 10 11 |
# File 'lib/tj_scale_ruby/configuration.rb', line 9 def monitor_process @monitor_process end |
#sidekiq_queues ⇒ Object (readonly)
Returns the value of attribute sidekiq_queues.
9 10 11 |
# File 'lib/tj_scale_ruby/configuration.rb', line 9 def sidekiq_queues @sidekiq_queues end |
Instance Method Details
#target_app ⇒ Object
Heroku app name the scaler should act on (defaults to HEROKU_APP_NAME when unset).
25 26 27 |
# File 'lib/tj_scale_ruby/configuration.rb', line 25 def target_app @target_app || @heroku_app_name end |
#target_process ⇒ Object
Process type to scale on that app: “web” or “worker”.
30 31 32 |
# File 'lib/tj_scale_ruby/configuration.rb', line 30 def target_process @target_process end |