class Eye::Trigger::Flapping

Public Instance Methods

check(transition) click to toggle source
# File lib/eye/trigger/flapping.rb, line 11
def check(transition)
  on_flapping if transition.event == :crashed && !good?
end

Private Instance Methods

good?() click to toggle source
# File lib/eye/trigger/flapping.rb, line 17
def good?
  states = process.states_history.states_for_period( within, @last_at )
  down_count = states.count{|st| st == :down }

  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 29
def on_flapping
  debug 'flapping recognized!!!'

  process.notify :error, 'flapping!'
  process.schedule :unmonitor, Eye::Reason.new(:flapping)

  return unless retry_in
  return if retry_times && process.flapping_times >= retry_times

  process.schedule_in(retry_in.to_f, :retry_start_after_flapping)
end