Class: Flapjack::Gateways::Jabber::Notifier

Inherits:
Object
  • Object
show all
Includes:
Utility
Defined in:
lib/flapjack/gateways/jabber.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {}) ⇒ Notifier

Returns a new instance of Notifier.



37
38
39
40
41
42
43
44
# File 'lib/flapjack/gateways/jabber.rb', line 37

def initialize(options = {})
  @lock = options[:lock]
  @config = options[:config]

  # TODO support for config reloading
  @queue = Flapjack::RecordQueue.new(@config['queue'] || 'jabber_notifications',
             Flapjack::Data::Alert)
end

Instance Attribute Details

#siblingsObject

Returns the value of attribute siblings.



35
36
37
# File 'lib/flapjack/gateways/jabber.rb', line 35

def siblings
  @siblings
end

Instance Method Details

#startObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/flapjack/gateways/jabber.rb', line 46

def start
  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_typeObject



62
63
64
# File 'lib/flapjack/gateways/jabber.rb', line 62

def stop_type
  :exception
end