Module: Pigeon::HealthCheck

Defined in:
lib/pigeon/health_check.rb,
lib/pigeon/health_check/kafka.rb,
lib/pigeon/health_check/queue.rb,
lib/pigeon/health_check/processor.rb

Overview

Health check module for Pigeon

Defined Under Namespace

Modules: Kafka, Processor, Queue

Class Method Summary collapse

Class Method Details

.determine_overall_status(components) ⇒ String

Determine the overall status based on component statuses

Parameters:

  • components (Array<Hash>)

    Component health check results

Returns:

  • (String)

    Overall status



53
54
55
56
57
58
59
60
61
# File 'lib/pigeon/health_check.rb', line 53

def self.determine_overall_status(components)
  if components.any? { |c| c[:status] == "critical" }
    "critical"
  elsif components.any? { |c| c[:status] == "warning" }
    "warning"
  else
    "healthy"
  end
end

.kafka_healthHash

Check the health of Kafka connectivity

Returns:

  • (Hash)

    Health check result



24
25
26
# File 'lib/pigeon/health_check.rb', line 24

def self.kafka_health
  Kafka.health
end

.processor_healthHash

Check the health of the processor

Returns:

  • (Hash)

    Health check result



12
13
14
# File 'lib/pigeon/health_check.rb', line 12

def self.processor_health
  Processor.health
end

.queue_healthHash

Check the health of the queue

Returns:

  • (Hash)

    Health check result



18
19
20
# File 'lib/pigeon/health_check.rb', line 18

def self.queue_health
  Queue.health
end

.statusHash

Get overall health status

Returns:

  • (Hash)

    Overall health status



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/pigeon/health_check.rb', line 30

def self.status
  processor = processor_health
  queue = queue_health
  kafka = kafka_health

  # Determine overall status (worst of all components)
  components = [processor, queue, kafka]
  status = determine_overall_status(components)

  {
    status: status,
    components: {
      processor: processor,
      queue: queue,
      kafka: kafka
    },
    timestamp: Time.now.iso8601
  }
end