Class: Kubernetes::Health::Config
- Inherits:
-
Object
- Object
- Kubernetes::Health::Config
- Defined in:
- lib/kubernetes/health/config.rb
Constant Summary collapse
- METRICS_PORT_FROM_PUMA_CONFIG =
File.read(File.join(Rails.root, 'config', 'puma.rb')).match(/kubernetes_url\s.+:(?<metrics_port>\d+)/)['metrics_port'] rescue nil
- @@live_if =
lambda { true }
- @@ready_if =
lambda { true }
- @@metrics_port =
ENV['KUBERNETES_HEALTH_METRICS_PORT'] || METRICS_PORT_FROM_PUMA_CONFIG || 9393
- @@enable_lock_on_migrate =
[true, 'true']
- @@enable_rack_on_migrate =
- @@enable_rack_on_sidekiq =
- @@route_liveness =
ENV['KUBERNETES_HEALTH_LIVENESS_ROUTE'] || '/_liveness'
- @@route_readiness =
ENV['KUBERNETES_HEALTH_READINESS_ROUTE'] || '/_readiness'
- @@route_metrics =
ENV['KUBERNETES_HEALTH_METRICS_ROUTE'] || '/_metrics'
- @@response_format =
ENV['KUBERNETES_HEALTH_RESPONSE_FORMAT'] || 'prometheus'
- @@request_log_callback =
lambda { |req, http_code, content| Rails.logger.debug "Kubernetes Health - Request: Path: #{req.path_info} / Params: #{req.params} / HTTP Code: #{http_code}\n#{content}" rescue nil }
- @@lock_or_wait =
lambda { ActiveRecord::Base.connection.execute "SET lock_timeout TO '3600s'; SELECT pg_advisory_lock(123456789123456789);" }
- @@unlock =
lambda { ActiveRecord::Base.connection.execute 'select pg_advisory_unlock(123456789123456789);' }
Class Method Summary collapse
- .enable_lock_on_migrate ⇒ Object
- .enable_lock_on_migrate=(value) ⇒ Object
- .enable_rack_on_migrate ⇒ Object
- .enable_rack_on_migrate=(value) ⇒ Object
- .enable_rack_on_sidekiq ⇒ Object
- .enable_rack_on_sidekiq=(value) ⇒ Object
- .live_if ⇒ Object
- .live_if=(value) ⇒ Object
- .lock_or_wait ⇒ Object
- .lock_or_wait=(value) ⇒ Object
- .metrics_port ⇒ Object
- .metrics_port=(value) ⇒ Object
- .ready_if ⇒ Object
- .ready_if=(value) ⇒ Object
- .request_log_callback ⇒ Object
- .request_log_callback=(value) ⇒ Object
- .response_format ⇒ Object
- .response_format=(value) ⇒ Object
- .route_liveness ⇒ Object
- .route_liveness=(value) ⇒ Object
- .route_metrics ⇒ Object
- .route_metrics=(value) ⇒ Object
- .route_readiness ⇒ Object
- .route_readiness=(value) ⇒ Object
- .unlock ⇒ Object
- .unlock=(value) ⇒ Object
Class Method Details
.enable_lock_on_migrate ⇒ Object
47 48 49 |
# File 'lib/kubernetes/health/config.rb', line 47 def self.enable_lock_on_migrate @@enable_lock_on_migrate end |
.enable_lock_on_migrate=(value) ⇒ Object
51 52 53 |
# File 'lib/kubernetes/health/config.rb', line 51 def self.enable_lock_on_migrate=(value) @@enable_lock_on_migrate = value end |
.enable_rack_on_migrate ⇒ Object
55 56 57 |
# File 'lib/kubernetes/health/config.rb', line 55 def self.enable_rack_on_migrate @@enable_rack_on_migrate end |
.enable_rack_on_migrate=(value) ⇒ Object
59 60 61 |
# File 'lib/kubernetes/health/config.rb', line 59 def self.enable_rack_on_migrate=(value) @@enable_rack_on_migrate = value end |
.enable_rack_on_sidekiq ⇒ Object
63 64 65 |
# File 'lib/kubernetes/health/config.rb', line 63 def self.enable_rack_on_sidekiq @@enable_rack_on_sidekiq end |
.enable_rack_on_sidekiq=(value) ⇒ Object
67 68 69 |
# File 'lib/kubernetes/health/config.rb', line 67 def self.enable_rack_on_sidekiq=(value) @@enable_rack_on_sidekiq = value end |
.live_if ⇒ Object
95 96 97 |
# File 'lib/kubernetes/health/config.rb', line 95 def self.live_if @@live_if end |
.live_if=(value) ⇒ Object
99 100 101 |
# File 'lib/kubernetes/health/config.rb', line 99 def self.live_if=(value) @@live_if = value end |
.lock_or_wait ⇒ Object
23 24 25 |
# File 'lib/kubernetes/health/config.rb', line 23 def self.lock_or_wait @@lock_or_wait end |
.lock_or_wait=(value) ⇒ Object
27 28 29 |
# File 'lib/kubernetes/health/config.rb', line 27 def self.lock_or_wait=(value) @@lock_or_wait = value end |
.metrics_port ⇒ Object
119 120 121 |
# File 'lib/kubernetes/health/config.rb', line 119 def self.metrics_port @@metrics_port end |
.metrics_port=(value) ⇒ Object
123 124 125 |
# File 'lib/kubernetes/health/config.rb', line 123 def self.metrics_port=(value) @@metrics_port = value end |
.ready_if ⇒ Object
103 104 105 |
# File 'lib/kubernetes/health/config.rb', line 103 def self.ready_if @@ready_if end |
.ready_if=(value) ⇒ Object
107 108 109 |
# File 'lib/kubernetes/health/config.rb', line 107 def self.ready_if=(value) @@ready_if = value end |
.request_log_callback ⇒ Object
31 32 33 |
# File 'lib/kubernetes/health/config.rb', line 31 def self.request_log_callback @@request_log_callback end |
.request_log_callback=(value) ⇒ Object
35 36 37 |
# File 'lib/kubernetes/health/config.rb', line 35 def self.request_log_callback=(value) @@request_log_callback = value end |
.response_format ⇒ Object
111 112 113 |
# File 'lib/kubernetes/health/config.rb', line 111 def self.response_format @@response_format end |
.response_format=(value) ⇒ Object
115 116 117 |
# File 'lib/kubernetes/health/config.rb', line 115 def self.response_format=(value) @@response_format = value end |
.route_liveness ⇒ Object
79 80 81 |
# File 'lib/kubernetes/health/config.rb', line 79 def self.route_liveness @@route_liveness end |
.route_liveness=(value) ⇒ Object
83 84 85 |
# File 'lib/kubernetes/health/config.rb', line 83 def self.route_liveness=(value) @@route_liveness = value end |
.route_metrics ⇒ Object
71 72 73 |
# File 'lib/kubernetes/health/config.rb', line 71 def self.route_metrics @@route_metrics end |
.route_metrics=(value) ⇒ Object
75 76 77 |
# File 'lib/kubernetes/health/config.rb', line 75 def self.route_metrics=(value) @@route_metrics = value end |
.route_readiness ⇒ Object
87 88 89 |
# File 'lib/kubernetes/health/config.rb', line 87 def self.route_readiness @@route_readiness end |
.route_readiness=(value) ⇒ Object
91 92 93 |
# File 'lib/kubernetes/health/config.rb', line 91 def self.route_readiness=(value) @@route_readiness = value end |
.unlock ⇒ Object
39 40 41 |
# File 'lib/kubernetes/health/config.rb', line 39 def self.unlock @@unlock end |
.unlock=(value) ⇒ Object
43 44 45 |
# File 'lib/kubernetes/health/config.rb', line 43 def self.unlock=(value) @@unlock = value end |