lib/bluepill/triggers/flapping.rb in bluepill-0.0.4 vs lib/bluepill/triggers/flapping.rb in bluepill-0.0.5
- old
+ new
@@ -1,9 +1,12 @@
module Bluepill
module Triggers
class Flapping < Bluepill::Trigger
- UP_TO_DOWN = [:up, :down] # to avoid recreating this array on every notify
+ TRIGGER_STATES = [
+ [:up, :down],
+ [:up, :restarting]
+ ]
PARAMS = [:times, :within, :retry_in]
attr_accessor *PARAMS
attr_reader :timeline
@@ -18,10 +21,10 @@
@timeline = Util::RotationalArray.new(@times)
super
end
def notify(transition)
- if [transition.from_name, transition.to_name] == UP_TO_DOWN
+ if TRIGGER_STATES.include?([transition.from_name, transition.to_name])
self.timeline << Time.now.to_i
self.check_flapping
end
end
\ No newline at end of file