Class: RailsPodKit::Config
- Inherits:
-
Anyway::Config
- Object
- Anyway::Config
- RailsPodKit::Config
- Defined in:
- lib/rails_pod_kit/config.rb
Overview
Backed by anyway_config: every attribute can also come from RAILS_POD_KIT_*
env vars or an optional config/rails_pod_kit.yml in the host, with the
RailsPodKit.configure block (running last, from an initializer) winning
over both. A single instance is memoized on the module.
Class Method Summary collapse
-
.default_enabled? ⇒ Boolean
True unless we're clearly in a test environment.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize(overrides = nil) ⇒ Config
constructor
A new instance of Config.
- #scheduler_enabled? ⇒ Boolean
Constructor Details
#initialize(overrides = nil) ⇒ Config
Returns a new instance of Config.
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rails_pod_kit/config.rb', line 87 def initialize(overrides = nil) super # Env/YAML sources deliver the policy as a string; the API is symbols. self.sidekiq_global_metrics = sidekiq_global_metrics.to_sym if sidekiq_global_metrics # Dynamic defaults anyway_config can't express statically. self.enabled = self.class.default_enabled? if enabled.nil? self.port ||= Integer(ENV.fetch('PROMETHEUS_EXPORTER_PORT', DEFAULT_PORT)) self.puma_control_url ||= ENV.fetch('PUMA_CONTROL_URL', 'tcp://127.0.0.1:9293') end |
Class Method Details
.default_enabled? ⇒ Boolean
True unless we're clearly in a test environment. Kept independent of Rails so the gem's own specs (which don't load the host app) get a safe default and never bind a socket.
109 110 111 112 |
# File 'lib/rails_pod_kit/config.rb', line 109 def self.default_enabled? env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] env != 'test' end |
Instance Method Details
#enabled? ⇒ Boolean
98 99 100 |
# File 'lib/rails_pod_kit/config.rb', line 98 def enabled? !!enabled end |
#scheduler_enabled? ⇒ Boolean
102 103 104 |
# File 'lib/rails_pod_kit/config.rb', line 102 def scheduler_enabled? !!scheduler_enabled end |