Class: SolidQueueGuard::Configuration
- Inherits:
-
Object
- Object
- SolidQueueGuard::Configuration
- Defined in:
- lib/solid_queue_guard/configuration.rb
Instance Attribute Summary collapse
-
#checks ⇒ Object
Returns the value of attribute checks.
-
#degraded_http_status ⇒ Object
Returns the value of attribute degraded_http_status.
-
#disabled_checks ⇒ Object
Returns the value of attribute disabled_checks.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#failed_jobs_threshold ⇒ Object
Returns the value of attribute failed_jobs_threshold.
-
#health_cache_ttl ⇒ Object
Returns the value of attribute health_cache_ttl.
-
#health_token ⇒ Object
Returns the value of attribute health_token.
-
#integrate_rails_health ⇒ Object
Returns the value of attribute integrate_rails_health.
-
#metrics_backends ⇒ Object
Returns the value of attribute metrics_backends.
-
#notify_with ⇒ Object
Returns the value of attribute notify_with.
-
#queue_lag_thresholds ⇒ Object
Returns the value of attribute queue_lag_thresholds.
-
#scheduled_backlog_threshold ⇒ Object
Returns the value of attribute scheduled_backlog_threshold.
-
#stale_process_threshold ⇒ Object
Returns the value of attribute stale_process_threshold.
-
#strict_mode ⇒ Object
Returns the value of attribute strict_mode.
-
#unhealthy_http_status ⇒ Object
Returns the value of attribute unhealthy_http_status.
Instance Method Summary collapse
- #check_enabled?(check_id) ⇒ Boolean
- #check_setting(check_id, key, default = nil) ⇒ Object
- #check_settings_for(check_id) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #strict? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/solid_queue_guard/configuration.rb', line 21 def initialize @enabled = true @queue_lag_thresholds = { default: 5.minutes } @failed_jobs_threshold = 20 @stale_process_threshold = 5.minutes @health_token = nil @strict_mode = false @health_cache_ttl = 15.seconds @scheduled_backlog_threshold = 100 @integrate_rails_health = false @notify_with = [:rails_logger] @metrics_backends = [] @disabled_checks = [] @checks = ActiveSupport::OrderedOptions.new @degraded_http_status = :ok @unhealthy_http_status = :service_unavailable end |
Instance Attribute Details
#checks ⇒ Object
Returns the value of attribute checks.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def checks @checks end |
#degraded_http_status ⇒ Object
Returns the value of attribute degraded_http_status.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def degraded_http_status @degraded_http_status end |
#disabled_checks ⇒ Object
Returns the value of attribute disabled_checks.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def disabled_checks @disabled_checks end |
#enabled ⇒ Object
Returns the value of attribute enabled.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def enabled @enabled end |
#failed_jobs_threshold ⇒ Object
Returns the value of attribute failed_jobs_threshold.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def failed_jobs_threshold @failed_jobs_threshold end |
#health_cache_ttl ⇒ Object
Returns the value of attribute health_cache_ttl.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def health_cache_ttl @health_cache_ttl end |
#health_token ⇒ Object
Returns the value of attribute health_token.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def health_token @health_token end |
#integrate_rails_health ⇒ Object
Returns the value of attribute integrate_rails_health.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def integrate_rails_health @integrate_rails_health end |
#metrics_backends ⇒ Object
Returns the value of attribute metrics_backends.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def metrics_backends @metrics_backends end |
#notify_with ⇒ Object
Returns the value of attribute notify_with.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def notify_with @notify_with end |
#queue_lag_thresholds ⇒ Object
Returns the value of attribute queue_lag_thresholds.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def queue_lag_thresholds @queue_lag_thresholds end |
#scheduled_backlog_threshold ⇒ Object
Returns the value of attribute scheduled_backlog_threshold.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def scheduled_backlog_threshold @scheduled_backlog_threshold end |
#stale_process_threshold ⇒ Object
Returns the value of attribute stale_process_threshold.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def stale_process_threshold @stale_process_threshold end |
#strict_mode ⇒ Object
Returns the value of attribute strict_mode.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def strict_mode @strict_mode end |
#unhealthy_http_status ⇒ Object
Returns the value of attribute unhealthy_http_status.
5 6 7 |
# File 'lib/solid_queue_guard/configuration.rb', line 5 def unhealthy_http_status @unhealthy_http_status end |
Instance Method Details
#check_enabled?(check_id) ⇒ Boolean
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/solid_queue_guard/configuration.rb', line 43 def check_enabled?(check_id) id = check_id.to_sym return false if disabled_checks.map(&:to_sym).include?(id) settings = check_settings_for(id) return true if settings.nil? enabled_value = settings[:enabled] enabled_value = settings['enabled'] if enabled_value.nil? enabled_value != false end |
#check_setting(check_id, key, default = nil) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/solid_queue_guard/configuration.rb', line 59 def check_setting(check_id, key, default = nil) settings = check_settings_for(check_id) return default unless settings value = settings[key] value = settings[key.to_sym] if value.nil? value.nil? ? default : value end |
#check_settings_for(check_id) ⇒ Object
55 56 57 |
# File 'lib/solid_queue_guard/configuration.rb', line 55 def check_settings_for(check_id) checks[check_id.to_sym] || checks[check_id.to_s] end |
#strict? ⇒ Boolean
39 40 41 |
# File 'lib/solid_queue_guard/configuration.rb', line 39 def strict? strict_mode || ActiveModel::Type::Boolean.new.cast(ENV.fetch('SOLID_QUEUE_GUARD_STRICT', nil)) end |