Module: RubyAemAws::HealthyStateVerifier

Included in:
Component::AuthorPrimary, Component::AuthorPublishDispatcher, Component::AuthorStandby, Component::ChaosMonkey, Component::Orchestrator
Defined in:
lib/ruby_aem_aws/mixins/healthy_state_verifier.rb

Overview

Mixin for checking health of a component via EC2 instance state. Add this to a component to make it capable of determining its own health.

Instance Method Summary collapse

Instance Method Details

#healthy?Boolean

Returns true if there are one or more instances matching the descriptor and they are all healthy.

Returns:

  • (Boolean)

    true if there are one or more instances matching the descriptor and they are all healthy.



22
23
24
25
26
27
28
29
30
# File 'lib/ruby_aem_aws/mixins/healthy_state_verifier.rb', line 22

def healthy?
  has_instance = false
  get_all_instances.each do |i|
    next if i.nil? || i.state.code != 16
    has_instance = true
    return false if i.state.name != Constants::INSTANCE_STATE_HEALTHY
  end
  has_instance
end

#wait_until_healthyObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/ruby_aem_aws/mixins/healthy_state_verifier.rb', line 32

def wait_until_healthy
  instance_healthy = false
  get_all_instances.each do |i|
    next if i.nil? || i.state.code != 16
    i.wait_until_running
    instance_healthy = true
    return false if i.state.name != Constants::INSTANCE_STATE_HEALTHY
  end
  instance_healthy
end