Sha256: 9b7f7da9b80d7219579f57e9bbbc1fa94a4747da2040a607dd532bbd8487b5cf

Contents?: true

Size: 624 Bytes

Versions: 7

Compression:

Stored size: 624 Bytes

Contents

class Eye::Trigger::Flapping < Eye::Trigger

  # triggers :flapping, :times => 10, :within => 1.minute, 
  #          :retry_in => 10.minutes, :retry_times => 15

  param :times, [Fixnum], true, 5
  param :within, [Float, Fixnum], true
  param :retry_in, [Float, Fixnum]
  param :retry_times, [Fixnum]

  def initialize(*args)
    super
    @last_at = nil
  end

  def good?
    states = @states_history.states_for_period( within, @last_at )
    down_count = states.count{|st| st == :down }

    if down_count >= times
      @last_at = @states_history.last_state_changed_at
      false
    else
      true
    end
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
reel-eye-0.3.2 lib/eye/trigger/flapping.rb
eye-0.3.2 lib/eye/trigger/flapping.rb
reel-eye-0.3.1 lib/eye/trigger/flapping.rb
eye-0.3.1 lib/eye/trigger/flapping.rb
eye-0.3 lib/eye/trigger/flapping.rb
eye-0.2.4 lib/eye/trigger/flapping.rb
eye-0.2.3 lib/eye/trigger/flapping.rb