Class: Puma::Kubernetes::App
- Inherits:
-
Object
- Object
- Puma::Kubernetes::App
- Defined in:
- lib/puma/kubernetes/app.rb
Instance Method Summary collapse
- #call(_env) ⇒ Object
-
#initialize(launcher) ⇒ App
constructor
A new instance of App.
Constructor Details
Instance Method Details
#call(_env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/puma/kubernetes/app.rb', line 15 def call(_env) req = ::Rack::Request.new(_env) type = {} content = [] case req.path_info when ::Kubernetes::Health::Config.route_liveness i_am_live = ::Kubernetes::Health::Config.live_if.arity == 0 ? ::Kubernetes::Health::Config.live_if.call : ::Kubernetes::Health::Config.live_if.call(req.params) http_code = i_am_live ? 200 : 503 when ::Kubernetes::Health::Config.route_readiness i_am_ready = ::Kubernetes::Health::Config.ready_if.arity == 0 ? ::Kubernetes::Health::Config.ready_if.call : ::Kubernetes::Health::Config.ready_if.call(req.params) http_code = i_am_ready ? 200 : 503 when ::Kubernetes::Health::Config.route_metrics http_code = 200 @parser.parse JSON.parse(@launcher.stats) type = { 'Content-Type' => 'text/plain' } content = [Prometheus::Client::Formats::Text.marshal(Prometheus::Client.registry)] else http_code = 404 end Rails.logger.info "Kubernetes Health: Puma Plugin - Request: Path: #{req.path_info} / Params: #{req.params} / HTTP Code: #{http_code}" rescue nil [http_code, type, content] end |