Class: Gitlab::HealthChecks::Probes::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/health_checks/probes/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*checks) ⇒ Collection

This accepts an array of objects implementing ‘:readiness` that returns `::Gitlab::HealthChecks::Result`



11
12
13
# File 'lib/gitlab/health_checks/probes/collection.rb', line 11

def initialize(*checks)
  @checks = checks
end

Instance Attribute Details

#checksObject (readonly)

Returns the value of attribute checks.



7
8
9
# File 'lib/gitlab/health_checks/probes/collection.rb', line 7

def checks
  @checks
end

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/health_checks/probes/collection.rb', line 15

def execute
  readiness = probe_readiness
  success = all_succeeded?(readiness)

  Probes::Status.new(
    success ? 200 : 503,
    status(success).merge(payload(readiness))
  )
rescue StandardError => e
  exception_payload = { message: "#{e.class} : #{e.message}" }

  Probes::Status.new(
    500,
    status(false).merge(exception_payload))
end