Module: StandardHealth
- Defined in:
- lib/standard_health.rb,
lib/standard_health/check.rb,
lib/standard_health/engine.rb,
lib/standard_health/version.rb,
lib/standard_health/env_spec.rb,
lib/standard_health/aggregator.rb,
lib/standard_health/configuration.rb,
lib/standard_health/checks/solid_cache.rb,
lib/standard_health/checks/solid_queue.rb,
lib/standard_health/checks/active_record.rb,
app/controllers/standard_health/health_controller.rb,
app/controllers/standard_health/application_controller.rb,
app/controllers/standard_health/diagnostics_controller.rb
Defined Under Namespace
Modules: Checks Classes: Aggregator, ApplicationController, Check, Configuration, DiagnosticsController, Engine, EnvSpec, HealthController
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
- .config ⇒ Object
-
.configure {|config| ... } ⇒ Object
Yields the configuration to a block.
-
.parent_controller ⇒ Object
Base controller for all StandardHealth endpoints.
-
.reset_config! ⇒ Object
Mostly useful in tests — wipes the singleton config so each example gets a clean slate.
-
.reset_parent_controller! ⇒ Object
Allow tests/host apps to bust the cached parent controller (e.g. when toggling config between examples).
Class Method Details
.config ⇒ Object
26 27 28 |
# File 'lib/standard_health.rb', line 26 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
Yields the configuration to a block.
StandardHealth.configure do |c|
c.parent_controller = "ApplicationController"
c.register_check :db, StandardHealth::Checks::ActiveRecord, critical: true
end
21 22 23 24 |
# File 'lib/standard_health.rb', line 21 def configure yield config if block_given? config end |
.parent_controller ⇒ Object
Base controller for all StandardHealth endpoints.
Lazily inherits from ‘StandardHealth.config.parent_controller` so host apps can wire their own auth/rate-limiting/before_actions in once and have them apply to /alive, /ready, and /diagnostics/env. The default is `ActionController::API` so the engine works in API-only host apps without configuration.
Resolution happens at the moment this class is first referenced, which is request time — by then the host app’s controllers are loaded and the constant resolves cleanly. Caching the resolved class on the singleton avoids re-running ‘constantize` per request.
16 17 18 |
# File 'app/controllers/standard_health/application_controller.rb', line 16 def self.parent_controller @parent_controller ||= config.parent_controller.constantize end |
.reset_config! ⇒ Object
Mostly useful in tests — wipes the singleton config so each example gets a clean slate.
32 33 34 |
# File 'lib/standard_health.rb', line 32 def reset_config! @config = Configuration.new end |
.reset_parent_controller! ⇒ Object
Allow tests/host apps to bust the cached parent controller (e.g. when toggling config between examples).
22 23 24 |
# File 'app/controllers/standard_health/application_controller.rb', line 22 def self.reset_parent_controller! @parent_controller = nil end |