queueing_rabbit 0.3.3 → 0.3.4
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.
- data/.gitignore +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +1 -0
- data/lib/queueing_rabbit.rb +23 -4
- data/lib/queueing_rabbit/callbacks.rb +1 -1
- data/lib/queueing_rabbit/client/amqp.rb +5 -1
- data/lib/queueing_rabbit/client/bunny.rb +44 -0
- data/lib/queueing_rabbit/extensions/threaded.rb +64 -0
- data/lib/queueing_rabbit/version.rb +1 -1
- data/lib/queueing_rabbit/worker.rb +4 -7
- data/spec/integration/asynchronous_publishing_and_consuming_spec.rb +1 -0
- data/spec/integration/asynchronous_publishing_and_consuming_with_retries_spec.rb +1 -0
- data/spec/integration/binary_synchronous_publishing_via_bus_and_asynchronous_consuming_via_job_spec.rb +2 -0
- data/spec/integration/configuration_spec.rb +2 -0
- data/spec/integration/direct_exchange_asynchronous_publishing_and_consuming_spec.rb +1 -0
- data/spec/integration/jobs/json_threaded_print_line_job.rb +24 -0
- data/spec/integration/jobs/print_line_job.rb +2 -0
- data/spec/integration/json_job_asynchronous_publishing_and_consuming_spec.rb +1 -0
- data/spec/integration/json_job_synchronous_publishing_and_consuming_spec.rb +50 -0
- data/spec/integration/json_synchronous_publishing_via_bus_and_asynchronous_consuming_via_job_spec.rb +2 -0
- data/spec/integration/persistent_asynchronous_publishing_and_consuming_spec.rb +1 -0
- data/spec/integration/synchronous_publishing_and_asynchronous_consuming_spec.rb +2 -0
- data/spec/integration/synchronous_publishing_and_consuming_spec.rb +29 -0
- data/spec/integration/synchronous_publishing_and_threaded_consuming_spec.rb +59 -0
- data/spec/integration/synchronous_publishing_spec.rb +1 -0
- data/spec/spec_helper.rb +0 -4
- data/spec/support/shared_contexts.rb +18 -1
- data/spec/unit/queueing_rabbit/client/amqp_spec.rb +3 -2
- data/spec/unit/queueing_rabbit/client/bunny_spec.rb +3 -0
- data/spec/unit/queueing_rabbit/extensions/new_relic_spec.rb +1 -0
- data/spec/unit/queueing_rabbit/extensions/threaded_spec.rb +42 -0
- data/spec/unit/queueing_rabbit/jobs/abstract_job_spec.rb +1 -0
- data/spec/unit/queueing_rabbit/worker_spec.rb +2 -7
- data/spec/unit/queueing_rabbit_spec.rb +14 -2
- metadata +32 -5
- checksums.yaml +0 -15
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/lib/queueing_rabbit.rb
CHANGED
@@ -23,6 +23,7 @@ module QueueingRabbit
|
|
23
23
|
extend Logging
|
24
24
|
extend Callbacks
|
25
25
|
extend Configuration
|
26
|
+
extend MonitorMixin
|
26
27
|
|
27
28
|
class QueueingRabbitError < Exception; end
|
28
29
|
class JobNotFoundError < QueueingRabbitError; end
|
@@ -31,13 +32,25 @@ module QueueingRabbit
|
|
31
32
|
attr_accessor :logger, :client
|
32
33
|
|
33
34
|
def connect
|
34
|
-
|
35
|
+
synchronize do
|
36
|
+
@connection ||= client.connect
|
37
|
+
end
|
38
|
+
end
|
39
|
+
alias_method :conn, :connect
|
40
|
+
alias_method :connection, :connect
|
41
|
+
|
42
|
+
def disconnect
|
43
|
+
synchronize do
|
44
|
+
if connected?
|
45
|
+
@connection.close
|
46
|
+
end
|
47
|
+
drop_connection
|
48
|
+
end
|
35
49
|
end
|
36
50
|
|
37
|
-
def
|
38
|
-
@connection
|
51
|
+
def connected?
|
52
|
+
@connection && @connection.open?
|
39
53
|
end
|
40
|
-
alias_method :conn, :connection
|
41
54
|
|
42
55
|
def drop_connection
|
43
56
|
@connection = nil
|
@@ -63,6 +76,12 @@ module QueueingRabbit
|
|
63
76
|
end
|
64
77
|
end
|
65
78
|
|
79
|
+
def begin_worker_loop
|
80
|
+
conn.begin_worker_loop do
|
81
|
+
yield
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
66
85
|
def follow_job_requirements(job)
|
67
86
|
follow_bus_requirements(job) do |ch, ex|
|
68
87
|
conn.define_queue(ch, job.queue_name, job.queue_options) do |q|
|
@@ -71,7 +71,11 @@ module QueueingRabbit
|
|
71
71
|
@event_machine_thread.join if @event_machine_thread
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
74
|
+
def open?
|
75
|
+
EM.reactor_running? && @connection.open?
|
76
|
+
end
|
77
|
+
|
78
|
+
def close
|
75
79
|
info "closing AMQP broker connection..."
|
76
80
|
|
77
81
|
connection.close do
|
@@ -6,6 +6,26 @@ module QueueingRabbit
|
|
6
6
|
|
7
7
|
class Bunny
|
8
8
|
|
9
|
+
class Metadata
|
10
|
+
|
11
|
+
def initialize(channel, delivery_info, properties)
|
12
|
+
@channel = channel
|
13
|
+
@delivery_info = delivery_info
|
14
|
+
@properties = properties
|
15
|
+
end
|
16
|
+
|
17
|
+
def ack
|
18
|
+
@channel.ack(@delivery_info.delivery_tag, false)
|
19
|
+
end
|
20
|
+
|
21
|
+
def headers
|
22
|
+
@properties.headers
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
include QueueingRabbit::Logging
|
28
|
+
|
9
29
|
attr_reader :connection
|
10
30
|
|
11
31
|
def self.connect
|
@@ -50,6 +70,30 @@ module QueueingRabbit
|
|
50
70
|
queue.status[:message_count]
|
51
71
|
end
|
52
72
|
|
73
|
+
def listen_queue(queue, options = {})
|
74
|
+
queue.subscribe(options) do |delivery_info, properties, payload|
|
75
|
+
begin
|
76
|
+
yield payload, Metadata.new(queue.channel, delivery_info, properties)
|
77
|
+
rescue => e
|
78
|
+
error "unexpected error #{e.class} occured: #{e.message}"
|
79
|
+
debug e
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def close
|
85
|
+
@connection.close
|
86
|
+
end
|
87
|
+
|
88
|
+
def open?
|
89
|
+
@connection.open?
|
90
|
+
end
|
91
|
+
|
92
|
+
def begin_worker_loop
|
93
|
+
yield
|
94
|
+
@connection.reader_loop.join
|
95
|
+
end
|
96
|
+
|
53
97
|
private
|
54
98
|
|
55
99
|
def initialize(connection)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'celluloid'
|
2
|
+
|
3
|
+
module QueueingRabbit
|
4
|
+
|
5
|
+
module JobExtensions
|
6
|
+
|
7
|
+
class Monitor
|
8
|
+
|
9
|
+
include Celluloid
|
10
|
+
|
11
|
+
trap_exit :report_error
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@logger = QueueingRabbit.logger
|
15
|
+
end
|
16
|
+
|
17
|
+
def report_error(obj, e)
|
18
|
+
return unless e
|
19
|
+
@logger.error "unexpected error #{e.class} occured."
|
20
|
+
@logger.debug e
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
module Threaded
|
26
|
+
|
27
|
+
def self.included(klass)
|
28
|
+
klass.send(:include, Celluloid)
|
29
|
+
klass.extend(ClassMethods)
|
30
|
+
end
|
31
|
+
|
32
|
+
def perform_and_terminate
|
33
|
+
perform
|
34
|
+
terminate
|
35
|
+
end
|
36
|
+
|
37
|
+
module ClassMethods
|
38
|
+
|
39
|
+
def perform(payload, metadata)
|
40
|
+
job = self.new(payload, metadata)
|
41
|
+
monitor.link(job)
|
42
|
+
job.async.perform_and_terminate
|
43
|
+
end
|
44
|
+
|
45
|
+
def monitor
|
46
|
+
create_monitor unless Celluloid::Actor[monitor_name]
|
47
|
+
Celluloid::Actor[monitor_name]
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_monitor
|
51
|
+
Monitor.supervise_as(monitor_name)
|
52
|
+
end
|
53
|
+
|
54
|
+
def monitor_name
|
55
|
+
:queueing_rabbit_monitor
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -10,20 +10,21 @@ module QueueingRabbit
|
|
10
10
|
sync_stdio
|
11
11
|
validate_jobs
|
12
12
|
constantize_jobs
|
13
|
-
use_asynchronous_client
|
14
13
|
end
|
15
14
|
|
16
15
|
def work
|
17
16
|
conn = QueueingRabbit.connection
|
18
17
|
trap_signals(conn)
|
19
18
|
|
19
|
+
QueueingRabbit.trigger_event(:worker_ready)
|
20
|
+
|
20
21
|
jobs.each { |job| run_job(conn, job) }
|
21
22
|
|
22
23
|
QueueingRabbit.trigger_event(:consuming_started)
|
23
24
|
end
|
24
25
|
|
25
26
|
def work!
|
26
|
-
|
27
|
+
QueueingRabbit.begin_worker_loop do
|
27
28
|
work
|
28
29
|
end
|
29
30
|
end
|
@@ -46,10 +47,6 @@ module QueueingRabbit
|
|
46
47
|
|
47
48
|
private
|
48
49
|
|
49
|
-
def use_asynchronous_client
|
50
|
-
QueueingRabbit.client = QueueingRabbit::Client::AMQP
|
51
|
-
end
|
52
|
-
|
53
50
|
def validate_jobs
|
54
51
|
if jobs.nil? || jobs.empty?
|
55
52
|
fatal "no jobs specified to work on."
|
@@ -94,7 +91,7 @@ module QueueingRabbit
|
|
94
91
|
|
95
92
|
def trap_signals(connection)
|
96
93
|
handler = Proc.new do
|
97
|
-
connection.
|
94
|
+
connection.close {
|
98
95
|
QueueingRabbit.trigger_event(:consuming_done)
|
99
96
|
remove_pidfile
|
100
97
|
}
|
@@ -2,6 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'integration/jobs/print_line_job'
|
3
3
|
|
4
4
|
describe 'Binary synchronous publishing via bus and asynchronous consuming via job' do
|
5
|
+
include_context "Auto-disconnect"
|
5
6
|
include_context "StringIO logger"
|
6
7
|
include_context "Evented spec"
|
7
8
|
|
@@ -19,6 +20,7 @@ describe 'Binary synchronous publishing via bus and asynchronous consuming via j
|
|
19
20
|
job.io = io
|
20
21
|
bus.publish(line)
|
21
22
|
QueueingRabbit.drop_connection
|
23
|
+
QueueingRabbit.client = QueueingRabbit::Client::AMQP
|
22
24
|
end
|
23
25
|
|
24
26
|
it "works" do
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'queueing_rabbit/extensions/threaded'
|
2
|
+
|
3
|
+
class JSONThreadedPrintLineJob < QueueingRabbit::JSONJob
|
4
|
+
|
5
|
+
class << self
|
6
|
+
attr_accessor :io
|
7
|
+
end
|
8
|
+
|
9
|
+
include QueueingRabbit::JobExtensions::Threaded
|
10
|
+
|
11
|
+
queue :auto_delete => true
|
12
|
+
|
13
|
+
listen :ack => true,
|
14
|
+
:block => false,
|
15
|
+
:consumer_tag => 'threaded-json-consumer'
|
16
|
+
|
17
|
+
def perform
|
18
|
+
raise arguments[:raise_error] if arguments[:raise_error]
|
19
|
+
|
20
|
+
self.class.io.puts arguments[:line]
|
21
|
+
acknowledge
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'integration/jobs/print_line_job'
|
3
|
+
|
4
|
+
describe "Synchronous publishing and consuming with JSON serialization" do
|
5
|
+
include_context "Auto-disconnect"
|
6
|
+
include_context "StringIO logger"
|
7
|
+
|
8
|
+
context "basic consuming" do
|
9
|
+
let(:line) { "Hello, world!" }
|
10
|
+
let(:job) {
|
11
|
+
Class.new(QueueingRabbit::JSONJob) do
|
12
|
+
class << self
|
13
|
+
attr_accessor :io
|
14
|
+
end
|
15
|
+
|
16
|
+
def perform
|
17
|
+
PrintLineFromJSONJob.io.puts arguments[:line]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
}
|
21
|
+
let(:job_name) { 'PrintLineFromJSONJob' }
|
22
|
+
let(:io) { StringIO.new }
|
23
|
+
let(:worker) { QueueingRabbit::Worker.new(job_name) }
|
24
|
+
|
25
|
+
before do
|
26
|
+
job.io = io
|
27
|
+
stub_const(job_name, job)
|
28
|
+
end
|
29
|
+
|
30
|
+
after do
|
31
|
+
QueueingRabbit.drop_connection
|
32
|
+
end
|
33
|
+
|
34
|
+
it "processes enqueued jobs" do
|
35
|
+
3.times { job.enqueue(:line => line) }
|
36
|
+
job.queue_size.should == 3
|
37
|
+
worker.work
|
38
|
+
job.queue_size.should be_zero
|
39
|
+
end
|
40
|
+
|
41
|
+
it "actually outputs the line" do
|
42
|
+
job.enqueue(:line => line)
|
43
|
+
worker.work
|
44
|
+
job.io.string.should include(line)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
data/spec/integration/json_synchronous_publishing_via_bus_and_asynchronous_consuming_via_job_spec.rb
CHANGED
@@ -2,6 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'integration/jobs/print_line_job'
|
3
3
|
|
4
4
|
describe 'JSON synchronous publishing via bus and asynchronous consuming via job' do
|
5
|
+
include_context "Auto-disconnect"
|
5
6
|
include_context "StringIO logger"
|
6
7
|
include_context "Evented spec"
|
7
8
|
|
@@ -36,6 +37,7 @@ describe 'JSON synchronous publishing via bus and asynchronous consuming via job
|
|
36
37
|
job.io = io
|
37
38
|
bus.publish(:line => line)
|
38
39
|
QueueingRabbit.drop_connection
|
40
|
+
QueueingRabbit.client = QueueingRabbit::Client::AMQP
|
39
41
|
end
|
40
42
|
|
41
43
|
it "works" do
|
@@ -2,6 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'integration/jobs/print_line_job'
|
3
3
|
|
4
4
|
describe "Synchronous publishing and asynchronous consuming example" do
|
5
|
+
include_context "Auto-disconnect"
|
5
6
|
include_context "StringIO logger"
|
6
7
|
include_context "Evented spec"
|
7
8
|
|
@@ -19,6 +20,7 @@ describe "Synchronous publishing and asynchronous consuming example" do
|
|
19
20
|
job.io = io
|
20
21
|
job.enqueue(line)
|
21
22
|
QueueingRabbit.drop_connection
|
23
|
+
QueueingRabbit.client = QueueingRabbit::Client::AMQP
|
22
24
|
end
|
23
25
|
|
24
26
|
it "works" do
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'integration/jobs/print_line_job'
|
3
|
+
|
4
|
+
describe "Synchronous publishing and asynchronous consuming example" do
|
5
|
+
include_context "Auto-disconnect"
|
6
|
+
include_context "StringIO logger"
|
7
|
+
|
8
|
+
let(:job) { PrintLineJob }
|
9
|
+
let(:line) { "Hello, world!" }
|
10
|
+
|
11
|
+
context "when a message is published and consumed synchronously" do
|
12
|
+
|
13
|
+
let(:worker) { QueueingRabbit::Worker.new(job.to_s) }
|
14
|
+
let(:io) { StringIO.new }
|
15
|
+
|
16
|
+
before do
|
17
|
+
job.io = io
|
18
|
+
job.enqueue(line)
|
19
|
+
end
|
20
|
+
|
21
|
+
specify do
|
22
|
+
worker.work
|
23
|
+
sleep 0.5
|
24
|
+
io.string.should include(line)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'integration/jobs/json_threaded_print_line_job' unless RUBY_VERSION == '1.8.7'
|
3
|
+
|
4
|
+
describe "Synchronous publishing and threaded consuming", :ruby => '1.8.7' do
|
5
|
+
include_context "Auto-disconnect"
|
6
|
+
include_context "StringIO logger"
|
7
|
+
|
8
|
+
context "basic consuming" do
|
9
|
+
|
10
|
+
let(:line) { "Hello, world!" }
|
11
|
+
let(:job) { JSONThreadedPrintLineJob }
|
12
|
+
let(:job_name) { 'JSONThreadedPrintLineJob' }
|
13
|
+
let(:io) { StringIO.new }
|
14
|
+
let(:worker) { QueueingRabbit::Worker.new(job_name) }
|
15
|
+
|
16
|
+
before do
|
17
|
+
QueueingRabbit.purge_queue(job)
|
18
|
+
Celluloid.logger = nil
|
19
|
+
job.io = io
|
20
|
+
end
|
21
|
+
|
22
|
+
it "processes enqueued jobs" do
|
23
|
+
worker.work
|
24
|
+
|
25
|
+
3.times { job.enqueue(:line => line) }
|
26
|
+
|
27
|
+
sleep 1
|
28
|
+
|
29
|
+
job.queue_size.should be_zero
|
30
|
+
end
|
31
|
+
|
32
|
+
it "actually outputs the line" do
|
33
|
+
worker.work
|
34
|
+
|
35
|
+
job.enqueue(:line => line)
|
36
|
+
|
37
|
+
sleep 0.5
|
38
|
+
|
39
|
+
job.io.string.should include(line)
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'on failure' do
|
43
|
+
|
44
|
+
it "handles errors gracefully" do
|
45
|
+
worker.work
|
46
|
+
|
47
|
+
job.enqueue({:raise_error => 'Some very unique message'})
|
48
|
+
|
49
|
+
sleep 0.5
|
50
|
+
|
51
|
+
@session_log.string.should include('Some very unique message')
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,8 @@ require 'stringio'
|
|
3
3
|
shared_context "StringIO logger" do
|
4
4
|
|
5
5
|
before(:all) do
|
6
|
-
|
6
|
+
@session_log = StringIO.new
|
7
|
+
QueueingRabbit.logger = Logger.new(@session_log)
|
7
8
|
end
|
8
9
|
|
9
10
|
after(:all) do
|
@@ -12,6 +13,22 @@ shared_context "StringIO logger" do
|
|
12
13
|
|
13
14
|
end
|
14
15
|
|
16
|
+
shared_context "Auto-disconnect" do
|
17
|
+
|
18
|
+
after(:each) do
|
19
|
+
QueueingRabbit.disconnect
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
shared_context "No existing connections" do
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
QueueingRabbit.drop_connection
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
15
32
|
shared_context "Evented spec" do
|
16
33
|
include EventedSpec::SpecHelper
|
17
34
|
end
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe QueueingRabbit::Client::AMQP do
|
4
4
|
|
5
5
|
include_context "StringIO logger"
|
6
|
+
include_context "No existing connections"
|
6
7
|
|
7
8
|
let(:connection) { mock :on_tcp_connection_loss => nil, :on_recovery => nil }
|
8
9
|
|
@@ -168,7 +169,7 @@ describe QueueingRabbit::Client::AMQP do
|
|
168
169
|
end
|
169
170
|
end
|
170
171
|
|
171
|
-
describe '#
|
172
|
+
describe '#close' do
|
172
173
|
before do
|
173
174
|
subject.should_receive(:info)
|
174
175
|
connection.should_receive(:close).and_yield
|
@@ -176,7 +177,7 @@ describe QueueingRabbit::Client::AMQP do
|
|
176
177
|
end
|
177
178
|
|
178
179
|
it 'writes the log, closes connection and stops the reactor' do
|
179
|
-
client.
|
180
|
+
client.close
|
180
181
|
end
|
181
182
|
end
|
182
183
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if RUBY_VERSION != '1.8.7'
|
4
|
+
require 'queueing_rabbit/extensions/threaded'
|
5
|
+
else
|
6
|
+
class QueueingRabbit::JobExtensions::Threaded; end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe QueueingRabbit::JobExtensions::Threaded, :ruby => '1.8.7' do
|
10
|
+
|
11
|
+
let(:test_job) {
|
12
|
+
Class.new(QueueingRabbit::AbstractJob) do
|
13
|
+
|
14
|
+
include QueueingRabbit::JobExtensions::Threaded
|
15
|
+
|
16
|
+
exchange 'test_job'
|
17
|
+
queue 'test_queue'
|
18
|
+
|
19
|
+
def perform
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
}
|
24
|
+
|
25
|
+
before do
|
26
|
+
Celluloid.logger = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'new class methods' do
|
30
|
+
subject { test_job }
|
31
|
+
|
32
|
+
it { should respond_to(:perform).with(2).arguments }
|
33
|
+
it { should respond_to(:monitor) }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'new instance methods' do
|
37
|
+
subject { test_job.new(mock, mock) }
|
38
|
+
|
39
|
+
it { should respond_to(:perform_and_terminate) }
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -56,11 +56,6 @@ describe QueueingRabbit::Worker do
|
|
56
56
|
|
57
57
|
it { should be }
|
58
58
|
it { should respond_to(:jobs) }
|
59
|
-
it 'changes used client to asynchronous' do
|
60
|
-
expect { creation.call }.to change { QueueingRabbit.client.to_s }.
|
61
|
-
from(QueueingRabbit::Client::Bunny.to_s).
|
62
|
-
to(QueueingRabbit::Client::AMQP.to_s)
|
63
|
-
end
|
64
59
|
end
|
65
60
|
end
|
66
61
|
|
@@ -100,8 +95,8 @@ describe QueueingRabbit::Worker do
|
|
100
95
|
end
|
101
96
|
|
102
97
|
describe '#work!' do
|
103
|
-
it 'runs #work and joins the
|
104
|
-
|
98
|
+
it 'runs #work and joins the connection thread' do
|
99
|
+
QueueingRabbit.should_receive(:begin_worker_loop).and_yield
|
105
100
|
subject.work!
|
106
101
|
end
|
107
102
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe QueueingRabbit do
|
4
|
+
include_context "No existing connections"
|
4
5
|
include_context "StringIO logger"
|
5
6
|
|
6
7
|
let(:connection) { mock }
|
@@ -23,8 +24,6 @@ describe QueueingRabbit do
|
|
23
24
|
:bind_queue? => true)
|
24
25
|
}
|
25
26
|
|
26
|
-
before(:each) { subject.drop_connection }
|
27
|
-
|
28
27
|
it { should respond_to(:logger) }
|
29
28
|
it { should respond_to(:client) }
|
30
29
|
|
@@ -67,6 +66,19 @@ describe QueueingRabbit do
|
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|
69
|
+
describe '.begin_worker_loop' do
|
70
|
+
|
71
|
+
before do
|
72
|
+
subject.instance_variable_set(:@connection, connection)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'begins the worker loop on opened connection' do
|
76
|
+
connection.should_receive(:begin_worker_loop).and_yield
|
77
|
+
expect { |b| subject.begin_worker_loop(&b) }.to yield_control
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
70
82
|
describe '.follow_job_requirements' do
|
71
83
|
let(:channel) { mock }
|
72
84
|
let(:exchange) { mock }
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queueing_rabbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Artem Chistyakov
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2014-01-02 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: amqp
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: bunny
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rake
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -55,6 +62,7 @@ dependencies:
|
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: json
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
67
|
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
@@ -62,6 +70,7 @@ dependencies:
|
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
75
|
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
@@ -102,6 +111,7 @@ files:
|
|
102
111
|
- lib/queueing_rabbit/extensions/direct_exchange.rb
|
103
112
|
- lib/queueing_rabbit/extensions/new_relic.rb
|
104
113
|
- lib/queueing_rabbit/extensions/retryable.rb
|
114
|
+
- lib/queueing_rabbit/extensions/threaded.rb
|
105
115
|
- lib/queueing_rabbit/job.rb
|
106
116
|
- lib/queueing_rabbit/jobs/abstract_job.rb
|
107
117
|
- lib/queueing_rabbit/jobs/json_job.rb
|
@@ -118,11 +128,15 @@ files:
|
|
118
128
|
- spec/integration/binary_synchronous_publishing_via_bus_and_asynchronous_consuming_via_job_spec.rb
|
119
129
|
- spec/integration/configuration_spec.rb
|
120
130
|
- spec/integration/direct_exchange_asynchronous_publishing_and_consuming_spec.rb
|
131
|
+
- spec/integration/jobs/json_threaded_print_line_job.rb
|
121
132
|
- spec/integration/jobs/print_line_job.rb
|
122
133
|
- spec/integration/json_job_asynchronous_publishing_and_consuming_spec.rb
|
134
|
+
- spec/integration/json_job_synchronous_publishing_and_consuming_spec.rb
|
123
135
|
- spec/integration/json_synchronous_publishing_via_bus_and_asynchronous_consuming_via_job_spec.rb
|
124
136
|
- spec/integration/persistent_asynchronous_publishing_and_consuming_spec.rb
|
125
137
|
- spec/integration/synchronous_publishing_and_asynchronous_consuming_spec.rb
|
138
|
+
- spec/integration/synchronous_publishing_and_consuming_spec.rb
|
139
|
+
- spec/integration/synchronous_publishing_and_threaded_consuming_spec.rb
|
126
140
|
- spec/integration/synchronous_publishing_spec.rb
|
127
141
|
- spec/spec_helper.rb
|
128
142
|
- spec/support/shared_contexts.rb
|
@@ -136,6 +150,7 @@ files:
|
|
136
150
|
- spec/unit/queueing_rabbit/extensions/direct_exchange_spec.rb
|
137
151
|
- spec/unit/queueing_rabbit/extensions/new_relic_spec.rb
|
138
152
|
- spec/unit/queueing_rabbit/extensions/retryable_spec.rb
|
153
|
+
- spec/unit/queueing_rabbit/extensions/threaded_spec.rb
|
139
154
|
- spec/unit/queueing_rabbit/jobs/abstract_job_spec.rb
|
140
155
|
- spec/unit/queueing_rabbit/jobs/json_job_spec.rb
|
141
156
|
- spec/unit/queueing_rabbit/logging_spec.rb
|
@@ -144,27 +159,34 @@ files:
|
|
144
159
|
- spec/unit/queueing_rabbit_spec.rb
|
145
160
|
homepage: https://github.com/temochka/queueing_rabbit
|
146
161
|
licenses: []
|
147
|
-
metadata: {}
|
148
162
|
post_install_message:
|
149
163
|
rdoc_options:
|
150
164
|
- --charset=UTF-8
|
151
165
|
require_paths:
|
152
166
|
- lib
|
153
167
|
required_ruby_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
154
169
|
requirements:
|
155
170
|
- - ! '>='
|
156
171
|
- !ruby/object:Gem::Version
|
157
172
|
version: '0'
|
173
|
+
segments:
|
174
|
+
- 0
|
175
|
+
hash: -573605060713824976
|
158
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
159
178
|
requirements:
|
160
179
|
- - ! '>='
|
161
180
|
- !ruby/object:Gem::Version
|
162
181
|
version: '0'
|
182
|
+
segments:
|
183
|
+
- 0
|
184
|
+
hash: -573605060713824976
|
163
185
|
requirements: []
|
164
186
|
rubyforge_project:
|
165
|
-
rubygems_version:
|
187
|
+
rubygems_version: 1.8.23
|
166
188
|
signing_key:
|
167
|
-
specification_version:
|
189
|
+
specification_version: 3
|
168
190
|
summary: QueueingRabbit is an AMQP-based queueing system
|
169
191
|
test_files:
|
170
192
|
- spec/integration/asynchronous_publishing_and_consuming_spec.rb
|
@@ -172,11 +194,15 @@ test_files:
|
|
172
194
|
- spec/integration/binary_synchronous_publishing_via_bus_and_asynchronous_consuming_via_job_spec.rb
|
173
195
|
- spec/integration/configuration_spec.rb
|
174
196
|
- spec/integration/direct_exchange_asynchronous_publishing_and_consuming_spec.rb
|
197
|
+
- spec/integration/jobs/json_threaded_print_line_job.rb
|
175
198
|
- spec/integration/jobs/print_line_job.rb
|
176
199
|
- spec/integration/json_job_asynchronous_publishing_and_consuming_spec.rb
|
200
|
+
- spec/integration/json_job_synchronous_publishing_and_consuming_spec.rb
|
177
201
|
- spec/integration/json_synchronous_publishing_via_bus_and_asynchronous_consuming_via_job_spec.rb
|
178
202
|
- spec/integration/persistent_asynchronous_publishing_and_consuming_spec.rb
|
179
203
|
- spec/integration/synchronous_publishing_and_asynchronous_consuming_spec.rb
|
204
|
+
- spec/integration/synchronous_publishing_and_consuming_spec.rb
|
205
|
+
- spec/integration/synchronous_publishing_and_threaded_consuming_spec.rb
|
180
206
|
- spec/integration/synchronous_publishing_spec.rb
|
181
207
|
- spec/spec_helper.rb
|
182
208
|
- spec/support/shared_contexts.rb
|
@@ -190,6 +216,7 @@ test_files:
|
|
190
216
|
- spec/unit/queueing_rabbit/extensions/direct_exchange_spec.rb
|
191
217
|
- spec/unit/queueing_rabbit/extensions/new_relic_spec.rb
|
192
218
|
- spec/unit/queueing_rabbit/extensions/retryable_spec.rb
|
219
|
+
- spec/unit/queueing_rabbit/extensions/threaded_spec.rb
|
193
220
|
- spec/unit/queueing_rabbit/jobs/abstract_job_spec.rb
|
194
221
|
- spec/unit/queueing_rabbit/jobs/json_job_spec.rb
|
195
222
|
- spec/unit/queueing_rabbit/logging_spec.rb
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
ZTk3ODlhMzY4N2ZkOGVmYWRkZmE3YzM2NDRkNzdkZDE3ZjhlZTZlMA==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Y2QzZDZkNzdiMmM1NmY4ZWZhMTE4ZGQzNTFmM2U5N2YyMDMyZmEwMA==
|
7
|
-
SHA512:
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MjFlYjE1ZmQ4ZGQ4MGQ1MGRmNjVjNGQzYzgxMGQ5NzAwNmE0NTY3M2IyMGI2
|
10
|
-
ZDNlYzRlZjFkZGQ3MTE0YmZmMGIzZjA3Njk0MjdiNTQ0ZWFkYmJiNzJlZDVj
|
11
|
-
NjRkZTllYTQwYzU5OWFlMmU4Njc0YjU5YTRhNDE2ZDcxOGYwODk=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OTNlYTBiMjJiNjcyYzEyZGQ4N2YzMjJjMTA1Yjg2NTRiZmQyNzc3OWQyOWZl
|
14
|
-
YWFiOTEzMTIwNTY3NzNhNzZkZDVhYWJlYmFlOWYxY2JiMjdlODQ0MjlkYTcx
|
15
|
-
ODI3NTJjOTEyZThlNTYyNTg4YWVlODk1MDg1MGQ1ODVjNjFmMGM=
|