Class: Flapjack::Notifier
- Inherits:
-
Object
- Object
- Flapjack::Notifier
show all
- Includes:
- Utility
- Defined in:
- lib/flapjack/notifier.rb
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(opts = {}) ⇒ Notifier
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/flapjack/notifier.rb', line 22
def initialize(opts = {})
@lock = opts[:lock]
@config = opts[:config] || {}
@queue = Flapjack::RecordQueue.new(@config['queue'] || 'notifications',
Flapjack::Data::Notification)
queue_configs = @config.find_all {|k, v| k =~ /_queue$/ }
@queues = Hash[queue_configs.map {|k, v|
[k[/^(.*)_queue$/, 1], Flapjack::RecordQueue.new(v, Flapjack::Data::Alert)]
}]
raise "No queues for media transports" if @queues.empty?
tz_string = @config['default_contact_timezone'] || ENV['TZ'] || 'UTC'
tz = ActiveSupport::TimeZone[tz_string.untaint]
if tz.nil?
raise "Invalid timezone string specified in default_contact_timezone or TZ (#{tz_string})"
end
@default_contact_timezone = tz
end
|
Instance Method Details
#start ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/flapjack/notifier.rb', line 44
def start
begin
Zermelo.redis = Flapjack.redis
loop do
@lock.synchronize do
@queue.foreach {|notif| process_notification(notif) }
end
@queue.wait
end
ensure
Flapjack.redis.quit
end
end
|
#stop_type ⇒ Object
60
61
62
|
# File 'lib/flapjack/notifier.rb', line 60
def stop_type
:exception
end
|