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/redactor.rb,
lib/standard_health/aggregator.rb,
lib/standard_health/subscribers.rb,
lib/standard_health/configuration.rb,
lib/standard_health/event_emitter.rb,
lib/standard_health/notifiers/logger.rb,
lib/standard_health/notifiers/sentry.rb,
lib/standard_health/notifiers/metrics.rb,
lib/standard_health/checks/solid_cable.rb,
lib/standard_health/checks/solid_cache.rb,
lib/standard_health/checks/solid_queue.rb,
lib/standard_health/checks/active_record.rb,
lib/standard_health/checks/env_spec_audit.rb,
app/controllers/standard_health/health_controller.rb,
app/controllers/standard_health/application_controller.rb,
app/controllers/standard_health/diagnostics_controller.rb,
lib/generators/standard_health/install/install_generator.rb,
app/controllers/standard_health/diagnostics_application_controller.rb
Defined Under Namespace
Modules: Checks, EventEmitter, Generators, Notifiers, Redactor Classes: Aggregator, ApplicationController, Check, CheckTimeout, Configuration, DiagnosticsApplicationController, DiagnosticsController, Engine, EnvSpec, HealthController, Subscribers
Constant Summary collapse
- VERSION =
"0.5.0"
Class Method Summary collapse
- .config ⇒ Object
-
.configure {|config| ... } ⇒ Object
Yields the configuration to a block.
-
.diagnostics_parent_controller ⇒ Object
Resolves the parent class for
DiagnosticsControlleronly. -
.parent_controller ⇒ Object
Resolves
config.parent_controllerto an actual class lazily — at the moment the engine'sApplicationControlleris first referenced (request time), by which point the host app's controllers are loaded. -
.reset_config! ⇒ Object
Mostly useful in tests — wipes the singleton config so each example gets a clean slate.
- .reset_diagnostics_parent_controller! ⇒ Object
- .reset_parent_controller! ⇒ Object
-
.subscribers ⇒ Object
The subscriber registry.
Class Method Details
.config ⇒ Object
36 37 38 |
# File 'lib/standard_health.rb', line 36 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
31 32 33 34 |
# File 'lib/standard_health.rb', line 31 def configure yield config if block_given? config end |
.diagnostics_parent_controller ⇒ Object
Resolves the parent class for DiagnosticsController only. Falls
back to config.parent_controller when no diagnostics-specific
parent is configured, preserving v0.1.0 behavior. When set, lets
host apps apply before_action :auth, only: :env to the diagnostics
endpoint without that callback leaking onto HealthController
(which would otherwise trip Rails 7.1's
raise_on_missing_callback_actions).
77 78 79 80 81 82 83 |
# File 'lib/standard_health.rb', line 77 def diagnostics_parent_controller expected = config.diagnostics_parent_controller || config.parent_controller if @diagnostics_parent_controller && @diagnostics_parent_controller.name != expected @diagnostics_parent_controller = nil end @diagnostics_parent_controller ||= expected.constantize end |
.parent_controller ⇒ Object
Resolves config.parent_controller to an actual class lazily — at
the moment the engine's ApplicationController is first referenced
(request time), by which point the host app's controllers are
loaded. Caching avoids re-running constantize per request, and
the name-mismatch reset lets tests swap config between examples.
58 59 60 61 62 63 64 |
# File 'lib/standard_health.rb', line 58 def parent_controller expected = config.parent_controller if @parent_controller && @parent_controller.name != expected @parent_controller = nil end @parent_controller ||= expected.constantize end |
.reset_config! ⇒ Object
Mostly useful in tests — wipes the singleton config so each example gets a clean slate.
42 43 44 |
# File 'lib/standard_health.rb', line 42 def reset_config! @config = Configuration.new end |
.reset_diagnostics_parent_controller! ⇒ Object
85 86 87 |
# File 'lib/standard_health.rb', line 85 def reset_diagnostics_parent_controller! @diagnostics_parent_controller = nil end |
.reset_parent_controller! ⇒ Object
66 67 68 |
# File 'lib/standard_health.rb', line 66 def reset_parent_controller! @parent_controller = nil end |
.subscribers ⇒ Object
The subscriber registry. Wired at boot by the engine initializer; also
callable directly so a host can re-run setup! after changing config
at runtime (and so tests can tear subscriptions down between examples).
49 50 51 |
# File 'lib/standard_health.rb', line 49 def subscribers @subscribers ||= Subscribers.new end |