superbolt 0.5.9 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/superbolt/app.rb +7 -10
- data/lib/superbolt/runner/default.rb +6 -6
- data/lib/superbolt/runner/pop.rb +7 -12
- data/lib/superbolt/version.rb +1 -1
- data/spec/app_spec.rb +28 -19
- data/spec/queue_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c78aea5b8060d528b43b74ac5c6939e137bad63
|
4
|
+
data.tar.gz: 9a660f7536bd590f3f2aad70f1bcf16b10a67b2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c06a247acb6b856c9c72078ffab1da9869df256de2eef70ce65b48b981dfd19b80b84d015cc51207b733984f99c7deed41cc8d2f3fb5c1d2c6368aa41f88cfe
|
7
|
+
data.tar.gz: e33cbf5336606dec0cb52e420b49a00c0d278721ed348e55abefc1ea6b2f08be918122bcac7adaed28cf10bebf1c77eed764b2bf2cb33a057415c806a4502deb
|
data/lib/superbolt/app.rb
CHANGED
@@ -41,13 +41,10 @@ module Superbolt
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def run(&block)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
quit(message)
|
49
|
-
end
|
50
|
-
end
|
44
|
+
@consumer = runner_class.new(queue, error_queue, logger, block).run
|
45
|
+
# quit_subscriber_queue.subscribe do |message|
|
46
|
+
# (message)
|
47
|
+
# end
|
51
48
|
end
|
52
49
|
|
53
50
|
def runner_class
|
@@ -70,9 +67,9 @@ module Superbolt
|
|
70
67
|
|
71
68
|
def quit(message='no message given')
|
72
69
|
logger.info "EXITING Superbolt App listening on queue #{name}: #{message}"
|
73
|
-
|
74
|
-
|
75
|
-
|
70
|
+
q.channel.consumers.first[0]
|
71
|
+
q.channel.basic_cancel q.channel.consumers.first[0]
|
72
|
+
close
|
76
73
|
end
|
77
74
|
end
|
78
75
|
end
|
@@ -11,13 +11,13 @@ module Superbolt
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def subscribe
|
14
|
-
queue.subscribe(ack: ack) do |delivery_info, metadata, payload|
|
15
|
-
|
14
|
+
queue.subscribe(ack: ack, block: true) do |delivery_info, metadata, payload|
|
16
15
|
message = Superbolt::IncomingMessage.new(delivery_info, payload, channel)
|
17
16
|
processor = processor_class.new(message, logger, &block)
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
processor.perform
|
18
|
+
# unless processor.perform
|
19
|
+
# on_error(message.parse, processor.exception)
|
20
|
+
# end
|
21
21
|
|
22
22
|
message.ack if ack
|
23
23
|
end
|
@@ -34,4 +34,4 @@ module Superbolt
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
end
|
37
|
+
end
|
data/lib/superbolt/runner/pop.rb
CHANGED
@@ -4,20 +4,15 @@ module Superbolt
|
|
4
4
|
attr_reader :message
|
5
5
|
|
6
6
|
def run
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@message = IncomingMessage.new(delivery_info, payload, channel)
|
13
|
-
processor = Processor.new(message, logger, &block)
|
14
|
-
unless processor.perform
|
15
|
-
on_error(message.parse, processor.exception) if message.parse
|
16
|
-
end
|
17
|
-
@message = nil
|
7
|
+
queue.subscribe(ack: false, block: true) do |delivery_info, metadata, payload|
|
8
|
+
@message = IncomingMessage.new(delivery_info, payload, channel)
|
9
|
+
processor = Processor.new(message, logger, &block)
|
10
|
+
unless processor.perform
|
11
|
+
on_error(message.parse, processor.exception) if message.parse
|
18
12
|
end
|
13
|
+
@message = nil
|
19
14
|
end
|
20
15
|
end
|
21
16
|
end
|
22
17
|
end
|
23
|
-
end
|
18
|
+
end
|
data/lib/superbolt/version.rb
CHANGED
data/spec/app_spec.rb
CHANGED
@@ -23,26 +23,33 @@ describe Superbolt::App do
|
|
23
23
|
error_queue.clear
|
24
24
|
end
|
25
25
|
|
26
|
+
after do
|
27
|
+
queue.clear
|
28
|
+
quit_queue.clear
|
29
|
+
error_queue.clear
|
30
|
+
end
|
26
31
|
|
27
32
|
shared_examples 'app' do
|
28
|
-
it "shuts down with any message to the quit queue" do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
33
|
+
# it "shuts down with any message to the quit queue" do
|
34
|
+
# queue.push({please: 'stop'})
|
35
|
+
# app.run do |arguments|
|
36
|
+
# quit_queue.push({message: 'just because'})
|
37
|
+
# end
|
34
38
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
39
|
+
# queue.size.should == 0
|
40
|
+
# quit_queue.size.should == 0
|
41
|
+
# end
|
38
42
|
|
39
43
|
it 'passes messages to the block for processing' do
|
40
44
|
queue.push({first: 1})
|
41
45
|
queue.push({last: 2})
|
46
|
+
messages = []
|
42
47
|
|
43
48
|
app.run do |message, logger|
|
44
49
|
messages << message
|
45
|
-
|
50
|
+
if messages.length > 1
|
51
|
+
app.quit
|
52
|
+
end
|
46
53
|
end
|
47
54
|
|
48
55
|
messages.size.should == 2
|
@@ -58,9 +65,10 @@ describe Superbolt::App do
|
|
58
65
|
|
59
66
|
app.run do |message, logger|
|
60
67
|
messages << message
|
61
|
-
|
68
|
+
if messages.length > 1
|
69
|
+
app.quit
|
70
|
+
end
|
62
71
|
end
|
63
|
-
|
64
72
|
queue.size.should == 0
|
65
73
|
end
|
66
74
|
|
@@ -79,44 +87,45 @@ describe Superbolt::App do
|
|
79
87
|
|
80
88
|
app.run do |message, logger|
|
81
89
|
logger.info(message)
|
82
|
-
quit_queue.push({message: 'stop!'})
|
90
|
+
# quit_queue.push({message: 'stop!'})
|
91
|
+
app.quit
|
83
92
|
end
|
84
93
|
|
85
94
|
message_received.should be_true
|
86
95
|
end
|
87
96
|
|
88
97
|
it "moves the message to an error queue if an exception is raised" do
|
98
|
+
pending "we will probably delete this test in favor of airbrake"
|
89
99
|
queue.push({oh: 'noes'})
|
90
100
|
|
91
101
|
app.run do |message|
|
92
|
-
quit_queue.push({message: 'halt thyself'})
|
102
|
+
# quit_queue.push({message: 'halt thyself'})
|
93
103
|
raise "something went wrong"
|
94
104
|
end
|
95
|
-
|
96
105
|
queue.size.should == 0
|
97
106
|
error_queue.size.should == 1
|
98
107
|
end
|
99
108
|
end
|
100
109
|
|
101
|
-
context 'when runner acknowledges one' do
|
110
|
+
context 'ACKONE: when runner acknowledges one' do
|
102
111
|
let(:runner) { :ack_one }
|
103
112
|
|
104
113
|
it_should_behave_like "app"
|
105
114
|
end
|
106
115
|
|
107
|
-
context 'when runner acknowledges without a prefetch limit' do
|
116
|
+
context 'ACK: when runner acknowledges without a prefetch limit' do
|
108
117
|
let(:runner) { :ack }
|
109
118
|
|
110
119
|
it_should_behave_like 'app'
|
111
120
|
end
|
112
121
|
|
113
|
-
context 'when runner does not acknowledge and has no limits' do
|
122
|
+
context 'GREEDY: when runner does not acknowledge and has no limits' do
|
114
123
|
let(:runner) { :greedy }
|
115
124
|
|
116
125
|
it_should_behave_like 'app'
|
117
126
|
end
|
118
127
|
|
119
|
-
context 'when the runner pops without acknowledgment' do
|
128
|
+
context 'POP: when the runner pops without acknowledgment' do
|
120
129
|
let(:runner) { :pop }
|
121
130
|
|
122
131
|
it_should_behave_like "app"
|
data/spec/queue_spec.rb
CHANGED
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.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- socialchorus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|