module RubyAemAws::HealthyStateVerifier
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.
Public Instance Methods
healthy?()
click to toggle source
@return true if there are one or more instances matching the descriptor and they are all healthy.
# 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()
click to toggle source
# 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