Module: Elasticsearch::Drain::Util
- Included in:
- AutoScaling
- Defined in:
- lib/elasticsearch/drain/util.rb
Instance Method Summary collapse
- #to_thor(name, message, color) ⇒ Object
- #wait_until(expected, max_attempts = 5, delay = 60, &block) ⇒ Object
Instance Method Details
#to_thor(name, message, color) ⇒ Object
19 20 21 22 |
# File 'lib/elasticsearch/drain/util.rb', line 19 def to_thor(name, , color) @thor_shell_client ||= Thor::Shell::Basic.new @thor_shell_client.say_status(name, , color) end |
#wait_until(expected, max_attempts = 5, delay = 60, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/elasticsearch/drain/util.rb', line 6 def wait_until(expected, max_attempts = 5, delay = 60, &block) 1.upto(max_attempts) do |i| result = block.call if result == expected return else to_thor('Waiting', "Waiting #{delay} seconds for #{i}/#{max_attempts} attempts", :yellow) sleep delay end end fail Errors::WaiterExpired end |