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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee5f785becf5300b3f3aa76a6309e345b33e6f89
4
- data.tar.gz: f91c93f3f9814d5a8e969ade48f06a76506276b8
3
+ metadata.gz: 2c78aea5b8060d528b43b74ac5c6939e137bad63
4
+ data.tar.gz: 9a660f7536bd590f3f2aad70f1bcf16b10a67b2c
5
5
  SHA512:
6
- metadata.gz: 26a593552635172c7e548c781b84846c63210536e57c2444e7b369e9518383bbd3b21856a644f1af8ff23395363dc725b4fa55cc4bf379605aa230c04a93899e
7
- data.tar.gz: 6a96bb6ed931e49acf07a8e0dfe3415565c63dfcf97f4bfcb4a456e8ad6ed13616e608f664f6fc6f5f6d6b57b61e40cbf529d6c5b4a41639982056d8cb37d5da
6
+ metadata.gz: 3c06a247acb6b856c9c72078ffab1da9869df256de2eef70ce65b48b981dfd19b80b84d015cc51207b733984f99c7deed41cc8d2f3fb5c1d2c6368aa41f88cfe
7
+ data.tar.gz: e33cbf5336606dec0cb52e420b49a00c0d278721ed348e55abefc1ea6b2f08be918122bcac7adaed28cf10bebf1c77eed764b2bf2cb33a057415c806a4502deb
@@ -41,13 +41,10 @@ module Superbolt
41
41
  end
42
42
 
43
43
  def run(&block)
44
- EventMachine.run do
45
- runner_class.new(queue, error_queue, logger, block).run
46
-
47
- quit_subscriber_queue.subscribe do |message|
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
- close {
74
- EventMachine.stop
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
- unless processor.perform
19
- on_error(message.parse, processor.exception)
20
- end
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
@@ -4,20 +4,15 @@ module Superbolt
4
4
  attr_reader :message
5
5
 
6
6
  def run
7
- EventMachine.add_periodic_timer(0.01) do
8
- next unless queue.message_count > 0
9
-
10
-
11
- queue.pop do |delivery_info, metadata, payload|
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
@@ -1,3 +1,3 @@
1
1
  module Superbolt
2
- VERSION = "0.5.9" #possibly broken for file transfer :(
2
+ VERSION = "0.6.0" #possibly broken for file transfer :(
3
3
  end
@@ -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
- queue.push({please: 'stop'})
30
-
31
- app.run do |arguments|
32
- quit_queue.push({message: 'just because'})
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
- queue.size.should == 0
36
- quit_queue.size.should == 0
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
- quit_queue.push({message: 'quit'}) if message['last']
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
- quit_queue.push({message: 'quit'}) if message['last']
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"
@@ -40,7 +40,7 @@ describe 'Superbolt::Queue' do
40
40
  it "returns the message but leaves it in the queue" do
41
41
  queue.push(message)
42
42
  queue.peek.should == decoded
43
- queue.size.should == 1
43
+ queue.size.should == 1
44
44
  end
45
45
  end
46
46
 
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.9
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-14 00:00:00.000000000 Z
11
+ date: 2014-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport