superbolt 0.5.5 → 0.5.6
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.
- checksums.yaml +4 -4
- data/Rakefile +22 -0
- data/lib/superbolt/app.rb +2 -11
- data/lib/superbolt/connection/queue.rb +6 -1
- data/lib/superbolt/router.rb +1 -1
- data/lib/superbolt/runner/default.rb +5 -3
- data/lib/superbolt/runner/pop.rb +6 -6
- data/lib/superbolt/version.rb +1 -1
- data/lib/tasks/superbolt.rake +1 -1
- data/spec/app_spec.rb +2 -2
- data/spec/support/em_mocking.rb +9 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 415111f64ddbfb854cc45718278e4d04dcc9629d
|
4
|
+
data.tar.gz: 1c5b6f516d6b51a2b217d9288f64281ed40098d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b007c47e99e43af1d766eb72ae36c64c9dd0a95d85b3702551151253e1f7ac3c50f1a2fd7d0c39e4ed61e999fd2106ce3585e24ee0e410a764bda42f257b2c19
|
7
|
+
data.tar.gz: 5de3ea41e8724daf828d2038137ab7840c73ccaf3235da65c91d06560f4167a477714929935b61f35eb15c16249863e5c4521de5e72dac18b0d9446fac84f840
|
data/Rakefile
CHANGED
@@ -1 +1,23 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require "superbolt/tasks"
|
3
|
+
|
4
|
+
|
5
|
+
# This one is for locally testing your crazy ideas
|
6
|
+
task :environment do
|
7
|
+
class MySleeperCell < Superbolt::MessageHandler
|
8
|
+
def perform
|
9
|
+
sleep(rand(10))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Superbolt.config = {
|
14
|
+
connection_params: {
|
15
|
+
host: '127.0.0.1',
|
16
|
+
heartbeat: 1,
|
17
|
+
}
|
18
|
+
}
|
19
|
+
Superbolt.app_name = 'food'
|
20
|
+
Superbolt::Router.routes = {
|
21
|
+
'do-it' => 'MySleeperCell'
|
22
|
+
}
|
23
|
+
end
|
data/lib/superbolt/app.rb
CHANGED
@@ -7,8 +7,8 @@ module Superbolt
|
|
7
7
|
@name = name
|
8
8
|
@env = options[:env] || Superbolt.env
|
9
9
|
@logger = options[:logger] || Logger.new($stdout)
|
10
|
-
@runner_type = options[:runner] || :default
|
11
10
|
@config = options[:config] || Superbolt.config
|
11
|
+
@runner_type = options[:runner] || :default
|
12
12
|
end
|
13
13
|
|
14
14
|
def name
|
@@ -25,7 +25,7 @@ module Superbolt
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def connection
|
28
|
-
@connection ||= Connection::
|
28
|
+
@connection ||= Connection::Queue.new(name, config)
|
29
29
|
end
|
30
30
|
|
31
31
|
delegate :close, :closing, :exclusive?, :durable?, :auto_delete?,
|
@@ -42,15 +42,6 @@ module Superbolt
|
|
42
42
|
|
43
43
|
def run(&block)
|
44
44
|
EventMachine.run do
|
45
|
-
queue.channel.auto_recovery = true
|
46
|
-
|
47
|
-
# LShift came up with this solution, which helps reconnect when
|
48
|
-
# a process runs longer than the heartbeat (and therefore disconnects)
|
49
|
-
queue.channel.connection.on_tcp_connection_loss do |conn, settings|
|
50
|
-
puts 'Lost TCP connection, reconnecting'
|
51
|
-
conn.reconnect(false, 2)
|
52
|
-
end
|
53
|
-
|
54
45
|
runner_class.new(queue, error_queue, logger, block).run
|
55
46
|
|
56
47
|
quit_subscriber_queue.subscribe do |message|
|
@@ -5,8 +5,9 @@ module Superbolt
|
|
5
5
|
@connection ||= Adapter::Bunny.new(config)
|
6
6
|
end
|
7
7
|
|
8
|
-
def close
|
8
|
+
def close(&block)
|
9
9
|
connection.close
|
10
|
+
block.call if block
|
10
11
|
@connection = nil
|
11
12
|
@q = nil
|
12
13
|
end
|
@@ -21,6 +22,10 @@ module Superbolt
|
|
21
22
|
q # to make sure it is connected
|
22
23
|
connection.exchange
|
23
24
|
end
|
25
|
+
|
26
|
+
def qq
|
27
|
+
@qq ||= connection.queue("#{name}.quit", self.class.default_options)
|
28
|
+
end
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
data/lib/superbolt/router.rb
CHANGED
@@ -11,12 +11,14 @@ module Superbolt
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def subscribe
|
14
|
-
queue.subscribe(ack: ack) do |metadata, payload|
|
15
|
-
|
16
|
-
|
14
|
+
queue.subscribe(ack: ack) do |delivery_info, metadata, payload|
|
15
|
+
|
16
|
+
message = Superbolt::IncomingMessage.new(delivery_info, payload, channel)
|
17
|
+
processor = Superbolt::Processor.new(message, logger, &block)
|
17
18
|
unless processor.perform
|
18
19
|
on_error(message.parse, processor.exception)
|
19
20
|
end
|
21
|
+
|
20
22
|
message.ack if ack
|
21
23
|
end
|
22
24
|
end
|
data/lib/superbolt/runner/pop.rb
CHANGED
@@ -2,17 +2,17 @@ module Superbolt
|
|
2
2
|
module Runner
|
3
3
|
class Pop < Base
|
4
4
|
attr_reader :message
|
5
|
-
|
5
|
+
|
6
6
|
def run
|
7
7
|
EventMachine.add_periodic_timer(0.01) do
|
8
|
-
next
|
8
|
+
next unless queue.message_count > 0
|
9
9
|
|
10
|
-
queue.pop do |metadata, payload|
|
11
|
-
@message = IncomingMessage.new(metadata, payload, channel)
|
12
|
-
processor = Processor.new(message, logger, &block)
|
13
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
14
|
unless processor.perform
|
15
|
-
on_error(message.parse, processor.exception)
|
15
|
+
on_error(message.parse, processor.exception) if message.parse
|
16
16
|
end
|
17
17
|
@message = nil
|
18
18
|
end
|
data/lib/superbolt/version.rb
CHANGED
data/lib/tasks/superbolt.rake
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# assumes an environment task that sets up your app environment
|
2
2
|
desc "worker that reads the queue and sends messages through the router as configured"
|
3
3
|
task :superbolt => :environment do
|
4
|
-
Superbolt::App.new(Superbolt.app_name).run do |message, logger|
|
4
|
+
Superbolt::App.new(Superbolt.app_name, {}).run do |message, logger|
|
5
5
|
Superbolt::Router.new(message, logger).perform
|
6
6
|
end
|
7
7
|
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
|
-
|
8
|
+
config: double('config', runner_type: runner_type, connection_params: true)
|
9
9
|
})
|
10
10
|
}
|
11
11
|
|
@@ -23,6 +23,7 @@ describe Superbolt::App do
|
|
23
23
|
error_queue.clear
|
24
24
|
end
|
25
25
|
|
26
|
+
|
26
27
|
shared_examples 'app' do
|
27
28
|
it "shuts down with any message to the quit queue" do
|
28
29
|
queue.push({please: 'stop'})
|
@@ -63,7 +64,6 @@ describe Superbolt::App do
|
|
63
64
|
queue.size.should == 0
|
64
65
|
end
|
65
66
|
|
66
|
-
|
67
67
|
it "passes a logger to the block" do
|
68
68
|
mock_logger = double
|
69
69
|
app.logger = mock_logger
|
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.6
|
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-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- spec/spec_helper.rb
|
177
177
|
- spec/superbolt_spec.rb
|
178
178
|
- spec/support/commodore.jpg
|
179
|
+
- spec/support/em_mocking.rb
|
179
180
|
- spec/support/queue_helpers.rb
|
180
181
|
- superbolt.gemspec
|
181
182
|
homepage: ''
|
@@ -198,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
199
|
version: '0'
|
199
200
|
requirements: []
|
200
201
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.
|
202
|
+
rubygems_version: 2.2.2
|
202
203
|
signing_key:
|
203
204
|
specification_version: 4
|
204
205
|
summary: Superbolt is a gem that makes SOA intra-app communication easy, via RabbitMQ
|
@@ -215,5 +216,5 @@ test_files:
|
|
215
216
|
- spec/spec_helper.rb
|
216
217
|
- spec/superbolt_spec.rb
|
217
218
|
- spec/support/commodore.jpg
|
219
|
+
- spec/support/em_mocking.rb
|
218
220
|
- spec/support/queue_helpers.rb
|
219
|
-
has_rdoc:
|