Module: RubyAemAws::HealthyStateVerifier
- 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
-
#healthy? ⇒ Boolean
True if there are one or more instances matching the descriptor and they are all healthy.
- #wait_until_healthy ⇒ Object
Instance Method Details
#healthy? ⇒ Boolean
Returns 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 31 |
# 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 != Constants::INSTANCE_STATE_CODE_RUNNING has_instance = true return false if i.state.name != Constants::INSTANCE_STATE_HEALTHY end has_instance end |
#wait_until_healthy ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruby_aem_aws/mixins/healthy_state_verifier.rb', line 33 def wait_until_healthy instance_healthy = false get_all_instances.each do |i| next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING i.wait_until_running instance_healthy = true return false if i.state.name != Constants::INSTANCE_STATE_HEALTHY end instance_healthy end |