superbolt 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 617269c18e96ede571c922d7382caed2b4c4a490
4
- data.tar.gz: 179415f08117fe92b14d85d183505b7afdb50bdf
3
+ metadata.gz: ee5f785becf5300b3f3aa76a6309e345b33e6f89
4
+ data.tar.gz: f91c93f3f9814d5a8e969ade48f06a76506276b8
5
5
  SHA512:
6
- metadata.gz: 5b57fb7e2441d5980c0f35a3e6a550a7afce8ec714767cb159b3e0b22231f1bc066a81537fe2f533d28601304a942e08c343bbf7f755858769289924a5ea42f0
7
- data.tar.gz: 5916fc473822704e98b3925bc7eff8f247239fd615da6f92882f737c400d1ebd20855a0dfb5be4d97685df3e013e2a88984bef88e65c2e2c86ae71d7fd7f38c6
6
+ metadata.gz: 26a593552635172c7e548c781b84846c63210536e57c2444e7b369e9518383bbd3b21856a644f1af8ff23395363dc725b4fa55cc4bf379605aa230c04a93899e
7
+ data.tar.gz: 6a96bb6ed931e49acf07a8e0dfe3415565c63dfcf97f4bfcb4a456e8ad6ed13616e608f664f6fc6f5f6d6b57b61e40cbf529d6c5b4a41639982056d8cb37d5da
data/lib/superbolt.rb CHANGED
@@ -25,6 +25,7 @@ require "superbolt/runner/ack_one"
25
25
  require "superbolt/runner/ack"
26
26
  require "superbolt/runner/pop"
27
27
  require "superbolt/runner/greedy"
28
+ require "superbolt/runner/pg"
28
29
 
29
30
  require "superbolt/queue"
30
31
  require "superbolt/incoming_message"
data/lib/superbolt/app.rb CHANGED
@@ -8,7 +8,7 @@ module Superbolt
8
8
  @env = options[:env] || Superbolt.env
9
9
  @logger = options[:logger] || Logger.new($stdout)
10
10
  @config = options[:config] || Superbolt.config
11
- @runner_type = options[:runner] || :default
11
+ @runner_type = options[:runner] || config.runner || :default
12
12
  end
13
13
 
14
14
  def name
@@ -59,7 +59,8 @@ module Superbolt
59
59
  pop: Runner::Pop,
60
60
  ack_one: Runner::AckOne,
61
61
  ack: Runner::Ack,
62
- greedy: Runner::Greedy
62
+ greedy: Runner::Greedy,
63
+ pg: Runner::Pg
63
64
  }
64
65
  end
65
66
 
@@ -23,6 +23,10 @@ module Superbolt
23
23
  options[:connection_key] || 'RABBITMQ_URL'
24
24
  end
25
25
 
26
+ def runner
27
+ options[:runner]
28
+ end
29
+
26
30
  def env_params
27
31
  ENV[env_connection_key]
28
32
  end
@@ -25,4 +25,4 @@ module Superbolt
25
25
  end
26
26
  end
27
27
  end
28
- end
28
+ end
@@ -0,0 +1,13 @@
1
+ module Superbolt
2
+ module Runner
3
+ class Pg < Default
4
+ def on_error(message, error)
5
+ if error == PG::UnableToSend || error == PG::ConnectionBad
6
+ ActiveRecord::Base.connection.reset!
7
+ end
8
+
9
+ super
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Superbolt
2
- VERSION = "0.5.8" #possibly broken for file transfer :(
2
+ VERSION = "0.5.9" #possibly broken for file transfer :(
3
3
  end
data/spec/app_spec.rb CHANGED
@@ -5,7 +5,7 @@ describe Superbolt::App do
5
5
  Superbolt::App.new(name, {
6
6
  env: env,
7
7
  logger: logger,
8
- config: double('config', runner_type: runner_type, connection_params: true)
8
+ config: double('config', runner: runner, connection_params: true)
9
9
  })
10
10
  }
11
11
 
@@ -99,25 +99,25 @@ describe Superbolt::App do
99
99
  end
100
100
 
101
101
  context 'when runner acknowledges one' do
102
- let(:runner_type) { :ack_one }
102
+ let(:runner) { :ack_one }
103
103
 
104
104
  it_should_behave_like "app"
105
105
  end
106
106
 
107
107
  context 'when runner acknowledges without a prefetch limit' do
108
- let(:runner_type) { :ack }
108
+ let(:runner) { :ack }
109
109
 
110
110
  it_should_behave_like 'app'
111
111
  end
112
112
 
113
113
  context 'when runner does not acknowledge and has no limits' do
114
- let(:runner_type) { :greedy }
114
+ let(:runner) { :greedy }
115
115
 
116
116
  it_should_behave_like 'app'
117
117
  end
118
118
 
119
119
  context 'when the runner pops without acknowledgment' do
120
- let(:runner_type) { :pop }
120
+ let(:runner) { :pop }
121
121
 
122
122
  it_should_behave_like "app"
123
123
  end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ module ActiveRecord
4
+ class Base
5
+ end
6
+ end
7
+
8
+ module PG
9
+ class UnableToSend
10
+ def self.message
11
+ 'oh noes'
12
+ end
13
+
14
+ def self.backtrace
15
+ 'trace me'
16
+ end
17
+ end
18
+
19
+ class ConnectionBad
20
+ def self.message
21
+ 'oh noes'
22
+ end
23
+
24
+ def self.backtrace
25
+ 'trace me'
26
+ end
27
+ end
28
+ end
29
+
30
+ describe "Superbolt::Runner::Pg" do
31
+ let(:runner) { Superbolt::Runner::Pg.new('berkin', double('error', push: true), 'whatever', 'some block') }
32
+ let(:connection) { double('connection', reset!: true) }
33
+
34
+ before do
35
+ ActiveRecord::Base.stub(:connection).and_return(connection)
36
+ end
37
+
38
+ describe "on_error" do
39
+ context "PG::UnableToSend" do
40
+ it "should handle it" do
41
+ connection.should_receive(:reset!).and_return(true)
42
+ runner.on_error({message: 'somethig has gone very wrong'}, PG::UnableToSend)
43
+ end
44
+ end
45
+
46
+ context "PG::ConnectionBad " do
47
+ it "should handle it" do
48
+ connection.should_receive(:reset!).and_return(true)
49
+ runner.on_error({message: 'somethig has gone very wrong'}, PG::ConnectionBad)
50
+ end
51
+ end
52
+ end
53
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superbolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - socialchorus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-15 00:00:00.000000000 Z
11
+ date: 2014-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -159,6 +159,7 @@ files:
159
159
  - lib/superbolt/runner/base.rb
160
160
  - lib/superbolt/runner/default.rb
161
161
  - lib/superbolt/runner/greedy.rb
162
+ - lib/superbolt/runner/pg.rb
162
163
  - lib/superbolt/runner/pop.rb
163
164
  - lib/superbolt/spec_helpers.rb
164
165
  - lib/superbolt/tasks.rb
@@ -170,6 +171,7 @@ files:
170
171
  - spec/file_packer_spec.rb
171
172
  - spec/file_unpacker_spec.rb
172
173
  - spec/incoming_message_spec.rb
174
+ - spec/lib/superbolt/runner/pg_spec.rb
173
175
  - spec/messenger_spec.rb
174
176
  - spec/queue_spec.rb
175
177
  - spec/router_spec.rb
@@ -210,6 +212,7 @@ test_files:
210
212
  - spec/file_packer_spec.rb
211
213
  - spec/file_unpacker_spec.rb
212
214
  - spec/incoming_message_spec.rb
215
+ - spec/lib/superbolt/runner/pg_spec.rb
213
216
  - spec/messenger_spec.rb
214
217
  - spec/queue_spec.rb
215
218
  - spec/router_spec.rb