Class: ElasticGraph::HealthCheck::HealthStatus
- Inherits:
-
Object
- Object
- ElasticGraph::HealthCheck::HealthStatus
- Defined in:
- lib/elastic_graph/health_check/health_status.rb
Overview
Encapsulates all of the status information for an ElasticGraph GraphQL endpoint. Computes a ‘category` for the status of the ElasticGraph endpoint.
- unhealthy: the endpoint should not be used
- degraded: the endpoint can be used, but prefer a healthy endpoint over it
- healthy: the endpoint should be used
Instance Method Summary collapse
-
#initialize(cluster_health_by_name:, latest_record_by_type:) ⇒ HealthStatus
constructor
A new instance of HealthStatus.
- #to_loggable_description ⇒ Object
Constructor Details
#initialize(cluster_health_by_name:, latest_record_by_type:) ⇒ HealthStatus
Returns a new instance of HealthStatus.
20 21 22 23 24 25 26 |
# File 'lib/elastic_graph/health_check/health_status.rb', line 20 def initialize(cluster_health_by_name:, latest_record_by_type:) super( cluster_health_by_name: cluster_health_by_name, latest_record_by_type: latest_record_by_type, category: compute_category(cluster_health_by_name, latest_record_by_type) ) end |
Instance Method Details
#to_loggable_description ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/elastic_graph/health_check/health_status.rb', line 28 def to_loggable_description latest_record_descriptions = latest_record_by_type .sort_by(&:first) # sort by type name .map { |type, record| record&.to_loggable_description(type) || "Latest #{type} (missing)" } .map { |description| "- #{description}" } cluster_health_descriptions = cluster_health_by_name .sort_by(&:first) # sort by cluster name .map { |name, health| "\n- #{health.to_loggable_description(name)}" } " HealthStatus: \#{category} (checked \#{cluster_health_by_name.size} clusters, \#{latest_record_by_type.size} latest records)\n \#{latest_record_descriptions.join(\"\\n\")}\n \#{cluster_health_descriptions.join(\"\\n\")}\n EOS\nend\n".strip.gsub("\n\n\n", "\n") |