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
- PROCESS_NAME =
Any Heroku process type (web, worker, bulk-worker, …) is monitorable; platform dynos never run app monitoring.
/\A[a-z][a-z0-9_-]*\z/- NON_APP_PROCESSES =
%w[release run scheduler console rake].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.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tj_scale_ruby/configuration.rb', line 16 def initialize(env = ENV) @monitor_process = normalize_process(env["TJ_SCALE_MONITOR_PROCESS"]) || process_from_dyno(env["DYNO"]) || "worker" @job_backend = normalize_job_backend(env["TJ_SCALE_JOB_BACKEND"]) @sidekiq_queues = parse_list( env[sidekiq_queues_key(@monitor_process)] || 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.
13 14 15 |
# File 'lib/tj_scale_ruby/configuration.rb', line 13 def interval_seconds @interval_seconds end |
#job_backend ⇒ Object (readonly)
Returns the value of attribute job_backend.
13 14 15 |
# File 'lib/tj_scale_ruby/configuration.rb', line 13 def job_backend @job_backend end |
#max_priority ⇒ Object (readonly)
Returns the value of attribute max_priority.
13 14 15 |
# File 'lib/tj_scale_ruby/configuration.rb', line 13 def max_priority @max_priority end |
#min_priority ⇒ Object (readonly)
Returns the value of attribute min_priority.
13 14 15 |
# File 'lib/tj_scale_ruby/configuration.rb', line 13 def min_priority @min_priority end |
#monitor_process ⇒ Object (readonly)
Returns the value of attribute monitor_process.
13 14 15 |
# File 'lib/tj_scale_ruby/configuration.rb', line 13 def monitor_process @monitor_process end |
#sidekiq_queues ⇒ Object (readonly)
Returns the value of attribute sidekiq_queues.
13 14 15 |
# File 'lib/tj_scale_ruby/configuration.rb', line 13 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).
32 33 34 |
# File 'lib/tj_scale_ruby/configuration.rb', line 32 def target_app @target_app || @heroku_app_name end |
#target_process ⇒ Object
Process type to scale on that app: “web” or “worker”.
37 38 39 |
# File 'lib/tj_scale_ruby/configuration.rb', line 37 def target_process @target_process end |