Class: Kirei::Controllers::Health
- Inherits:
-
Kirei::Controller
- Object
- Routing::Base
- Kirei::Controller
- Kirei::Controllers::Health
- Extended by:
- T::Sig
- Defined in:
- lib/kirei/controllers/health.rb
Overview
Built-in health check controller implementing Kubernetes API health endpoints.
Provides three endpoints following the Kubernetes convention:
- /livez — Liveness probe. Indicates the process is alive.
- /readyz — Readiness probe. Verifies downstream dependencies (DB) are reachable.
- /healthz — Deprecated alias for /livez (deprecated since Kubernetes v1.16).
Reference: kubernetes.io/docs/reference/using-api/health-checks/
Constant Summary
Constants inherited from Routing::Base
Instance Attribute Summary
Attributes inherited from Routing::Base
Instance Method Summary collapse
- #livez ⇒ Object (also: #healthz)
- #readyz ⇒ Object
Methods inherited from Kirei::Controller
Methods inherited from Routing::Base
#add_cors_headers, #call, #default_headers, #initialize, #render, #render_error, #render_json, #render_result
Constructor Details
This class inherits a constructor from Kirei::Routing::Base
Instance Method Details
#livez ⇒ Object Also known as: healthz
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kirei/controllers/health.rb', line 20 def livez info = { "status" => "ok", "version" => App.version, "app_name" => App.config.app_name, "environment" => App.environment, "req_host" => request.host, "req_port" => request.port, "req_ssl" => request.ssl?, } Kirei::Logging::Logger.call( level: Kirei::Logging::Level::INFO, label: "Health check", meta: info, ) render_json(info, status: 200) end |
#readyz ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/kirei/controllers/health.rb', line 42 def readyz T.unsafe(App.raw_db_connection).execute("SELECT 1") Kirei::Logging::Logger.call( level: Kirei::Logging::Level::INFO, label: "Readiness check", meta: { "status" => "ok" }, ) render_json({ "status" => "ok" }, status: 200) rescue Sequel::Error => e Kirei::Logging::Logger.call( level: Kirei::Logging::Level::ERROR, label: "Readiness check failed", meta: { "error" => e. }, ) render_json({ "status" => "unavailable", "reason" => e. }, status: 503) end |