Class: SidekiqVigil::HealthApp
- Inherits:
-
Object
- Object
- SidekiqVigil::HealthApp
- Defined in:
- lib/sidekiq_vigil/health_app.rb
Constant Summary collapse
- JSON_HEADERS =
{ "content-type" => "application/json", "cache-control" => "no-store" }.freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(storage:, interval:, clock: -> { Time.now }) ⇒ HealthApp
constructor
A new instance of HealthApp.
Constructor Details
#initialize(storage:, interval:, clock: -> { Time.now }) ⇒ HealthApp
Returns a new instance of HealthApp.
10 11 12 13 14 |
# File 'lib/sidekiq_vigil/health_app.rb', line 10 def initialize(storage:, interval:, clock: -> { Time.now }) @storage = storage @interval = interval @clock = clock end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sidekiq_vigil/health_app.rb', line 16 def call(env) return response(405, error: "method not allowed") unless env["REQUEST_METHOD"] == "GET" case env["PATH_INFO"] when "/healthz" then health when "/status.json" then status else response(404, error: "not found") end rescue StandardError => e response(503, healthy: false, error: "snapshot unavailable", detail: e.class.name) end |