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 +4 -4
- data/lib/superbolt.rb +1 -0
- data/lib/superbolt/app.rb +3 -2
- data/lib/superbolt/config.rb +4 -0
- data/lib/superbolt/runner/base.rb +1 -1
- data/lib/superbolt/runner/pg.rb +13 -0
- data/lib/superbolt/version.rb +1 -1
- data/spec/app_spec.rb +5 -5
- data/spec/lib/superbolt/runner/pg_spec.rb +53 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee5f785becf5300b3f3aa76a6309e345b33e6f89
|
4
|
+
data.tar.gz: f91c93f3f9814d5a8e969ade48f06a76506276b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26a593552635172c7e548c781b84846c63210536e57c2444e7b369e9518383bbd3b21856a644f1af8ff23395363dc725b4fa55cc4bf379605aa230c04a93899e
|
7
|
+
data.tar.gz: 6a96bb6ed931e49acf07a8e0dfe3415565c63dfcf97f4bfcb4a456e8ad6ed13616e608f664f6fc6f5f6d6b57b61e40cbf529d6c5b4a41639982056d8cb37d5da
|
data/lib/superbolt.rb
CHANGED
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
|
|
data/lib/superbolt/config.rb
CHANGED
data/lib/superbolt/version.rb
CHANGED
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',
|
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(:
|
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(:
|
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(:
|
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(:
|
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.
|
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-
|
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
|