Class: Orchestration::ServiceCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/orchestration/service_check.rb

Constant Summary collapse

ATTEMPT_LIMIT =
ENV.fetch('ORCHESTRATION_RETRY_LIMIT', '10').to_i
RETRY_INTERVAL =
ENV.fetch('ORCHESTRATION_RETRY_INTERVAL', '5').to_i

Instance Method Summary collapse

Constructor Details

#initialize(service, terminal, options = {}) ⇒ ServiceCheck

Returns a new instance of ServiceCheck.



8
9
10
11
12
13
14
15
16
# File 'lib/orchestration/service_check.rb', line 8

def initialize(service, terminal, options = {})
  @service = service
  @service_name = service.service_name
  @terminal = terminal
  @attempt_limit = options.fetch(:attempt_limit, ATTEMPT_LIMIT)
  @retry_interval = options.fetch(:retry_interval, RETRY_INTERVAL)
  @attempts = 0
  @failure_callback = options.fetch(:failure_callback, nil)
end

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
# File 'lib/orchestration/service_check.rb', line 18

def run
  return echo_missing unless @service.configuration.configured?

  echo_start
  success = attempt_connection
  echo_ready if success
  success
end