Class: SolidQueueGuard::Configuration
- Inherits:
-
Object
- Object
- SolidQueueGuard::Configuration
- Defined in:
- lib/solid_queue_guard/configuration.rb
Defined Under Namespace
Classes: ValidationError
Constant Summary collapse
- HTTP_STATUS_OPTIONS =
HttpStatusPolicy::STATUS_MAP.keys.freeze
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_mission_control ⇒ Object
Returns the value of attribute integrate_mission_control.
-
#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.
-
#on_status_change ⇒ Object
Returns the value of attribute on_status_change.
-
#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
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/solid_queue_guard/configuration.rb', line 27 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 @integrate_mission_control = false @notify_with = [:rails_logger] @metrics_backends = [] @disabled_checks = [] @checks = ActiveSupport::OrderedOptions.new @degraded_http_status = :ok @unhealthy_http_status = :service_unavailable @on_status_change = nil end |
Instance Attribute Details
#checks ⇒ Object
Returns the value of attribute checks.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def checks @checks end |
#degraded_http_status ⇒ Object
Returns the value of attribute degraded_http_status.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def degraded_http_status @degraded_http_status end |
#disabled_checks ⇒ Object
Returns the value of attribute disabled_checks.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def disabled_checks @disabled_checks end |
#enabled ⇒ Object
Returns the value of attribute enabled.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def enabled @enabled end |
#failed_jobs_threshold ⇒ Object
Returns the value of attribute failed_jobs_threshold.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def failed_jobs_threshold @failed_jobs_threshold end |
#health_cache_ttl ⇒ Object
Returns the value of attribute health_cache_ttl.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def health_cache_ttl @health_cache_ttl end |
#health_token ⇒ Object
Returns the value of attribute health_token.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def health_token @health_token end |
#integrate_mission_control ⇒ Object
Returns the value of attribute integrate_mission_control.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def integrate_mission_control @integrate_mission_control end |
#integrate_rails_health ⇒ Object
Returns the value of attribute integrate_rails_health.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def integrate_rails_health @integrate_rails_health end |
#metrics_backends ⇒ Object
Returns the value of attribute metrics_backends.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def metrics_backends @metrics_backends end |
#notify_with ⇒ Object
Returns the value of attribute notify_with.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def notify_with @notify_with end |
#on_status_change ⇒ Object
Returns the value of attribute on_status_change.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def on_status_change @on_status_change end |
#queue_lag_thresholds ⇒ Object
Returns the value of attribute queue_lag_thresholds.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def queue_lag_thresholds @queue_lag_thresholds end |
#scheduled_backlog_threshold ⇒ Object
Returns the value of attribute scheduled_backlog_threshold.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def scheduled_backlog_threshold @scheduled_backlog_threshold end |
#stale_process_threshold ⇒ Object
Returns the value of attribute stale_process_threshold.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def stale_process_threshold @stale_process_threshold end |
#strict_mode ⇒ Object
Returns the value of attribute strict_mode.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def strict_mode @strict_mode end |
#unhealthy_http_status ⇒ Object
Returns the value of attribute unhealthy_http_status.
9 10 11 |
# File 'lib/solid_queue_guard/configuration.rb', line 9 def unhealthy_http_status @unhealthy_http_status end |
Instance Method Details
#check_enabled?(check_id) ⇒ Boolean
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/solid_queue_guard/configuration.rb', line 62 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
78 79 80 81 82 83 84 85 |
# File 'lib/solid_queue_guard/configuration.rb', line 78 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
74 75 76 |
# File 'lib/solid_queue_guard/configuration.rb', line 74 def check_settings_for(check_id) checks[check_id.to_sym] || checks[check_id.to_s] end |
#strict? ⇒ Boolean
58 59 60 |
# File 'lib/solid_queue_guard/configuration.rb', line 58 def strict? strict_mode || ActiveModel::Type::Boolean.new.cast(ENV.fetch('SOLID_QUEUE_GUARD_STRICT', nil)) end |
#validate! ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/solid_queue_guard/configuration.rb', line 47 def validate! validate_http_status!(:degraded_http_status, degraded_http_status) validate_http_status!(:unhealthy_http_status, unhealthy_http_status) validate_duration!(:stale_process_threshold, stale_process_threshold) validate_duration!(:health_cache_ttl, health_cache_ttl) validate_positive_integer!(:failed_jobs_threshold, failed_jobs_threshold) validate_positive_integer!(:scheduled_backlog_threshold, scheduled_backlog_threshold) validate_callback!(:on_status_change, on_status_change) self end |