Class: God::Behaviors::NotifyWhenFlapping
- Inherits:
-
God::Behavior
- Object
- God::Behavior
- God::Behaviors::NotifyWhenFlapping
- Defined in:
- lib/god/behaviors/notify_when_flapping.rb
Instance Attribute Summary collapse
-
#failures ⇒ Object
number of failures.
-
#notifier ⇒ Object
number of failures.
-
#seconds ⇒ Object
number of failures.
Attributes inherited from God::Behavior
Instance Method Summary collapse
- #before_restart ⇒ Object
- #before_start ⇒ Object
-
#initialize ⇒ NotifyWhenFlapping
constructor
A new instance of NotifyWhenFlapping.
- #valid? ⇒ Boolean
Methods inherited from God::Behavior
#after_restart, #after_start, #after_stop, #before_stop, #friendly_name, generate
Methods included from Configurable
#base_name, complain, #complain, #friendly_name, #prepare, #reset
Constructor Details
#initialize ⇒ NotifyWhenFlapping
Returns a new instance of NotifyWhenFlapping.
10 11 12 13 |
# File 'lib/god/behaviors/notify_when_flapping.rb', line 10 def initialize super @startup_times = [] end |
Instance Attribute Details
#failures ⇒ Object
number of failures
6 7 8 |
# File 'lib/god/behaviors/notify_when_flapping.rb', line 6 def failures @failures end |
#notifier ⇒ Object
number of failures
6 7 8 |
# File 'lib/god/behaviors/notify_when_flapping.rb', line 6 def notifier @notifier end |
#seconds ⇒ Object
number of failures
6 7 8 |
# File 'lib/god/behaviors/notify_when_flapping.rb', line 6 def seconds @seconds end |
Instance Method Details
#before_restart ⇒ Object
35 36 37 38 39 |
# File 'lib/god/behaviors/notify_when_flapping.rb', line 35 def before_restart now = Time.now.to_i @startup_times << now check_for_flapping(now) end |
#before_start ⇒ Object
29 30 31 32 33 |
# File 'lib/god/behaviors/notify_when_flapping.rb', line 29 def before_start now = Time.now.to_i @startup_times << now check_for_flapping(now) end |
#valid? ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/god/behaviors/notify_when_flapping.rb', line 15 def valid? valid = true valid &= complain("Attribute 'failures' must be specified", self) unless failures valid &= complain("Attribute 'seconds' must be specified", self) unless seconds valid &= complain("Attribute 'notifier' must be specified", self) unless notifier # Must take one arg or variable args unless notifier.respond_to?(:notify) && [1, -1].include?(notifier.method(:notify).arity) valid &= complain("The 'notifier' must have a method 'notify' which takes 1 or variable args", self) end valid end |