class Eye::Trigger::Flapping
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
Eye::Trigger::new
# File lib/eye/trigger/flapping.rb, line 13 def initialize(*args) super clear_counters end
Public Instance Methods
check(transition)
click to toggle source
# File lib/eye/trigger/flapping.rb, line 18 def check(transition) on_flapping if transition.event == :crashed && !good? end
Private Instance Methods
clear_counters()
click to toggle source
# File lib/eye/trigger/flapping.rb, line 24 def clear_counters @retry_times = 0 @reretry_times = 0 end
good?()
click to toggle source
# File lib/eye/trigger/flapping.rb, line 29 def good? down_count = 0 process.states_history.states_for_period(within, @last_at) do |s| down_count += 1 if s[:state] == :down end if down_count >= times @last_at = process.states_history.last_state_changed_at false else true end end
on_flapping()
click to toggle source
# File lib/eye/trigger/flapping.rb, line 43 def on_flapping debug { 'flapping recognized!!!' } process.notify :error, 'flapping!' process.schedule command: :unmonitor, by: :flapping return unless retry_in if !retry_times || (retry_times && @retry_times < retry_times) @retry_times += 1 process.schedule(in: retry_in.to_f, command: :conditional_start, by: :flapping, reason: 'retry start after flapping') elsif reretry_in && !reretry_times || (reretry_times && @reretry_times < reretry_times) @retry_times = 0 @reretry_times += 1 process.schedule(in: reretry_in.to_f, command: :conditional_start, by: :flapping, reason: 'reretry start after flapping') end end