Class: Flapjack::Gateways::PagerDuty::Notifier
- Inherits:
-
Object
- Object
- Flapjack::Gateways::PagerDuty::Notifier
- Includes:
- Utility
- Defined in:
- lib/flapjack/gateways/pager_duty.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Notifier
constructor
A new instance of Notifier.
- #start ⇒ Object
- #stop_type ⇒ Object
Methods included from Utility
#hashify, #load_template, #local_timezone, #relative_time_ago, #remove_utc_offset, #stringify, #symbolize, #time_period_in_words, #truncate
Constructor Details
#initialize(opts = {}) ⇒ Notifier
Returns a new instance of Notifier.
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/flapjack/gateways/pager_duty.rb', line 69 def initialize(opts = {}) @lock = opts[:lock] @config = opts[:config] # TODO support for config reloading @queue = Flapjack::RecordQueue.new(@config['queue'] || 'pagerduty_notifications', Flapjack::Data::Alert) Flapjack.logger.debug("New PagerDuty::Notifier pikelet with the following options: #{@config.inspect}") end |
Instance Method Details
#start ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/flapjack/gateways/pager_duty.rb', line 80 def start until Flapjack::Gateways::PagerDuty.test_pagerduty_connection Flapjack.logger.error("Can't connect to the PagerDuty API, retrying after 10 seconds") Kernel.sleep(10) end begin Zermelo.redis = Flapjack.redis loop do @lock.synchronize do @queue.foreach {|alert| handle_alert(alert) } end @queue.wait end ensure Flapjack.redis.quit end end |
#stop_type ⇒ Object
101 102 103 |
# File 'lib/flapjack/gateways/pager_duty.rb', line 101 def stop_type :exception end |