flapjack 0.6.31 → 0.6.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/flapjack-populator +2 -1
- data/dist/etc/init.d/flapper +1 -1
- data/lib/flapjack/configuration.rb +2 -1
- data/lib/flapjack/coordinator.rb +5 -1
- data/lib/flapjack/data/event.rb +1 -1
- data/lib/flapjack/executive.rb +0 -2
- data/lib/flapjack/jabber.rb +1 -1
- data/lib/flapjack/pagerduty.rb +1 -1
- data/lib/flapjack/pikelet.rb +7 -1
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/jabber_spec.rb +4 -1
- metadata +1 -1
data/bin/flapjack-populator
CHANGED
|
@@ -13,6 +13,7 @@ end
|
|
|
13
13
|
require 'flapjack/configuration'
|
|
14
14
|
require 'flapjack/data/contact'
|
|
15
15
|
require 'flapjack/data/entity'
|
|
16
|
+
require 'flapjack/data/event'
|
|
16
17
|
|
|
17
18
|
options = OpenStruct.new
|
|
18
19
|
options.config = File.join('etc', 'flapjack_config.yaml')
|
|
@@ -92,7 +93,7 @@ when "import-entities"
|
|
|
92
93
|
|
|
93
94
|
when "purge-events"
|
|
94
95
|
@persistence = get_redis_connection(config_env['redis'])
|
|
95
|
-
Flapjack::Data
|
|
96
|
+
Flapjack::Data::Event.purge_all(:redis => @persistence)
|
|
96
97
|
@persistence.quit
|
|
97
98
|
|
|
98
99
|
else
|
data/dist/etc/init.d/flapper
CHANGED
data/lib/flapjack/coordinator.rb
CHANGED
|
@@ -227,8 +227,12 @@ module Flapjack
|
|
|
227
227
|
end
|
|
228
228
|
|
|
229
229
|
def build_redis_connection_pool(options = {})
|
|
230
|
+
redis_em_options = @redis_options.dup
|
|
231
|
+
redis_db = redis_em_options.delete(:db)
|
|
230
232
|
EventMachine::Synchrony::ConnectionPool.new(:size => options[:size] || 5) do
|
|
231
|
-
::Redis.
|
|
233
|
+
redis = EM::Protocols::Redis.connect(redis_em_options)
|
|
234
|
+
redis.select(redis_db)
|
|
235
|
+
redis
|
|
232
236
|
end
|
|
233
237
|
end
|
|
234
238
|
|
data/lib/flapjack/data/event.rb
CHANGED
|
@@ -23,7 +23,7 @@ module Flapjack
|
|
|
23
23
|
|
|
24
24
|
# In production, we wait indefinitely for events coming from other systems.
|
|
25
25
|
if block
|
|
26
|
-
raw = opts[:persistence].blpop('events').last
|
|
26
|
+
raw = opts[:persistence].blpop('events', 0).last
|
|
27
27
|
event = ::JSON.parse(raw)
|
|
28
28
|
self.new(event)
|
|
29
29
|
else
|
data/lib/flapjack/executive.rb
CHANGED
|
@@ -25,8 +25,6 @@ module Flapjack
|
|
|
25
25
|
|
|
26
26
|
def setup
|
|
27
27
|
@redis = build_redis_connection_pool
|
|
28
|
-
redis_client_status = @redis.client
|
|
29
|
-
@logger.debug("Flapjack::Executive.initialize: @redis client status: " + redis_client_status.inspect)
|
|
30
28
|
|
|
31
29
|
@queues = {:email => @config['email_queue'],
|
|
32
30
|
:sms => @config['sms_queue'],
|
data/lib/flapjack/jabber.rb
CHANGED
|
@@ -271,7 +271,7 @@ module Flapjack
|
|
|
271
271
|
# before joining the group chat rooms)
|
|
272
272
|
if connected?
|
|
273
273
|
logger.debug("jabber is connected so commencing blpop on #{queue}")
|
|
274
|
-
events[queue] = @redis.blpop(queue)
|
|
274
|
+
events[queue] = @redis.blpop(queue, 0)
|
|
275
275
|
event = Yajl::Parser.parse(events[queue][1])
|
|
276
276
|
type = event['notification_type']
|
|
277
277
|
logger.debug('jabber notification event received')
|
data/lib/flapjack/pagerduty.rb
CHANGED
|
@@ -186,7 +186,7 @@ module Flapjack
|
|
|
186
186
|
|
|
187
187
|
until should_quit?
|
|
188
188
|
logger.debug("pagerduty gateway is going into blpop mode on #{queue}")
|
|
189
|
-
events[queue] = @redis.blpop(queue)
|
|
189
|
+
events[queue] = @redis.blpop(queue, 0)
|
|
190
190
|
event = Yajl::Parser.parse(events[queue][1])
|
|
191
191
|
type = event['notification_type']
|
|
192
192
|
logger.debug("pagerduty notification event popped off the queue: " + event.inspect)
|
data/lib/flapjack/pikelet.rb
CHANGED
|
@@ -27,9 +27,15 @@ module Flapjack
|
|
|
27
27
|
def build_redis_connection_pool(options = {})
|
|
28
28
|
return unless @bootstrapped
|
|
29
29
|
if defined?(EventMachine) && defined?(EventMachine::Synchrony)
|
|
30
|
+
|
|
31
|
+
redis_em_options = @redis_config.dup
|
|
32
|
+
redis_db = redis_em_options.delete(:db)
|
|
30
33
|
EventMachine::Synchrony::ConnectionPool.new(:size => options[:size] || 5) do
|
|
31
|
-
::Redis.
|
|
34
|
+
r = EM::Protocols::Redis.connect(redis_em_options)
|
|
35
|
+
r.select(redis_db)
|
|
36
|
+
r
|
|
32
37
|
end
|
|
38
|
+
|
|
33
39
|
else
|
|
34
40
|
::Redis.new(@redis_config)
|
|
35
41
|
end
|
data/lib/flapjack/version.rb
CHANGED
|
@@ -25,6 +25,7 @@ describe Flapjack::Jabber do
|
|
|
25
25
|
|
|
26
26
|
fj = Flapjack::Jabber.new
|
|
27
27
|
fj.bootstrap(:config => config)
|
|
28
|
+
fj.should_receive(:build_redis_connection_pool)
|
|
28
29
|
|
|
29
30
|
EM.should_receive(:next_tick).exactly(4).times.and_yield
|
|
30
31
|
EM.should_receive(:synchrony).exactly(4).times.and_yield
|
|
@@ -48,6 +49,8 @@ describe Flapjack::Jabber do
|
|
|
48
49
|
fj = Flapjack::Jabber.new
|
|
49
50
|
fj.bootstrap(:config => config)
|
|
50
51
|
|
|
52
|
+
fj.should_receive(:build_redis_connection_pool)
|
|
53
|
+
|
|
51
54
|
fj.should_receive(:connected?).and_return(true)
|
|
52
55
|
fj.should_receive(:write).with(an_instance_of(Blather::Stanza::Presence))
|
|
53
56
|
fj.should_receive(:write).with(an_instance_of(Blather::Stanza::Message))
|
|
@@ -131,10 +134,10 @@ describe Flapjack::Jabber do
|
|
|
131
134
|
EM::Synchrony.should_receive(:add_periodic_timer).with(60).and_return(timer_2)
|
|
132
135
|
|
|
133
136
|
redis = mock('redis')
|
|
134
|
-
EventMachine::Synchrony::ConnectionPool.should_receive(:new).and_return(redis)
|
|
135
137
|
|
|
136
138
|
fj = Flapjack::Jabber.new
|
|
137
139
|
fj.bootstrap(:config => config)
|
|
140
|
+
fj.should_receive(:build_redis_connection_pool).and_return(redis)
|
|
138
141
|
fj.should_receive(:register_handler).exactly(4).times
|
|
139
142
|
|
|
140
143
|
fj.should_receive(:connect)
|