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.
@@ -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.Event.purge_all(:redis => @persistence)
96
+ Flapjack::Data::Event.purge_all(:redis => @persistence)
96
97
  @persistence.quit
97
98
 
98
99
  else
@@ -21,7 +21,7 @@ fi
21
21
 
22
22
  # Evaluate command
23
23
 
24
- rbenv shell 1.9.3-p125 && flapper
24
+ rbenv shell 1.9.3-p125 && flapper-control $1
25
25
  RETVAL=$?
26
26
 
27
27
  exit $RETVAL
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'yaml'
4
+ require 'logger'
4
5
 
5
6
  module Flapjack
6
7
 
@@ -60,4 +61,4 @@ module Flapjack
60
61
 
61
62
  end
62
63
 
63
- end
64
+ end
@@ -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.new(@redis_options.merge(:driver => (options[:driver] || 'synchrony')))
233
+ redis = EM::Protocols::Redis.connect(redis_em_options)
234
+ redis.select(redis_db)
235
+ redis
232
236
  end
233
237
  end
234
238
 
@@ -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
@@ -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'],
@@ -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')
@@ -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)
@@ -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.new(@redis_config.merge(:driver => 'synchrony'))
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
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  module Flapjack
4
- VERSION = "0.6.31"
4
+ VERSION = "0.6.32"
5
5
  end
@@ -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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flapjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.31
4
+ version: 0.6.32
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: