queueing_rabbit 0.1.0.rc1 → 0.1.0.rc2

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/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.8.7"
4
+ - "1.9.2"
5
+ - "1.9.3"
6
+ - "2.0.0"
7
+ services:
8
+ - rabbitmq
9
+ script: bundle exec rake spec
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # QueueingRabbit
1
+ # QueueingRabbit [![Build Status](https://travis-ci.org/temochka/queueing_rabbit.png?branch=master)](https://travis-ci.org/temochka/queueing_rabbit) [![Code Climate](https://codeclimate.com/github/temochka/queueing_rabbit.png)](https://codeclimate.com/github/temochka/queueing_rabbit)
2
2
 
3
3
  QueueingRabbit is a Ruby library that provides a convenient object-oriented
4
4
  syntax for managing background jobs with AMQP. All jobs' argumets are
5
5
  serialized to JSON and transfered as AMQP message payloads. The library
6
6
  implements amqp and bunny gems as adapters, making it possible to use
7
7
  synchronous publishing and asynchronous consuming, which might be useful for
8
- Rails app running on non-EventMachine based application servers (i. e.
8
+ Rails apps running on non-EventMachine based application servers (i. e.
9
9
  Passenger).
10
10
 
11
11
  ## Installation
@@ -81,8 +81,8 @@ module QueueingRabbit
81
81
  end
82
82
 
83
83
  def listen_queue(channel, queue_name, options={}, &block)
84
- define_queue(channel, queue_name, options)
85
- .subscribe(:ack => true) do |metadata, payload|
84
+ define_queue(channel, queue_name, options).
85
+ subscribe(:ack => true) do |metadata, payload|
86
86
  begin
87
87
  process_message(deserialize(payload), &block)
88
88
  metadata.ack
@@ -0,0 +1,20 @@
1
+ module QueueingRabbit
2
+
3
+ module Extensions
4
+
5
+ module NewRelic
6
+
7
+ def self.included(mod)
8
+ mod.class_eval do |klass|
9
+ class << klass
10
+ include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
11
+ add_transaction_tracer :perform, :category => :task
12
+ end
13
+ end
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -1,3 +1,3 @@
1
1
  module QueueingRabbit
2
- VERSION = "0.1.0.rc1"
2
+ VERSION = "0.1.0.rc2"
3
3
  end
@@ -6,9 +6,9 @@ require "queueing_rabbit/serializer"
6
6
  require "queueing_rabbit/client/callbacks"
7
7
  require "queueing_rabbit/client/amqp"
8
8
  require "queueing_rabbit/client/bunny"
9
+ require "queueing_rabbit/extensions/new_relic"
9
10
  require "queueing_rabbit/job"
10
11
  require "queueing_rabbit/worker"
11
- # require "queueing_rabbit/new_relic"
12
12
 
13
13
  module QueueingRabbit
14
14
  extend self
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency "amqp", ">= 0.9.0"
21
21
  gem.add_dependency "bunny", ">= 0.9.0.pre7"
22
22
  gem.add_dependency "rake", ">= 0"
23
+ gem.add_dependency "json", ">= 0"
23
24
 
24
25
  gem.description = <<description
25
26
  QueueingRabbit is a Ruby library providing convenient object-oriented syntax
@@ -12,7 +12,7 @@ describe "Synchronous publishing and asynchronous consuming example" do
12
12
 
13
13
  context "when a message is published synchronously" do
14
14
  before do
15
- QueueingRabbit.publish(job, line: line)
15
+ QueueingRabbit.publish(job, :line => line)
16
16
  QueueingRabbit.drop_connection
17
17
  end
18
18
 
@@ -12,12 +12,12 @@ describe "Synchronous publishing example" do
12
12
  end
13
13
 
14
14
  let(:publishing) {
15
- -> { QueueingRabbit.publish(job, line: "Hello, World!") }
15
+ lambda { QueueingRabbit.publish(job, :line => "Hello, World!") }
16
16
  }
17
17
 
18
18
  it 'affects the queue size' do
19
- expect { 5.times { publishing.call } }
20
- .to change{QueueingRabbit.queue_size(job)}.by(5)
19
+ expect { 5.times { publishing.call } }.
20
+ to change{QueueingRabbit.queue_size(job)}.by(5)
21
21
  end
22
22
  end
23
23
 
@@ -1,5 +1,5 @@
1
1
  shared_examples :client do
2
-
2
+
3
3
  describe '#define_queue' do
4
4
  let(:exchange) { mock }
5
5
  let(:channel) { mock }
@@ -10,12 +10,12 @@ shared_examples :client do
10
10
 
11
11
  before do
12
12
  client.stub(:exchange => exchange)
13
- channel.should_receive(:queue).with(queue_name, options)
14
- .and_yield(queue)
15
- queue.should_receive(:bind)
16
- .with(exchange, :routing_key => routing_keys.first.to_s).ordered
17
- queue.should_receive(:bind)
18
- .with(exchange, :routing_key => queue_name).ordered
13
+ channel.should_receive(:queue).with(queue_name, options).
14
+ and_yield(queue)
15
+ queue.should_receive(:bind).
16
+ with(exchange, :routing_key => routing_keys.first.to_s).ordered
17
+ queue.should_receive(:bind).
18
+ with(exchange, :routing_key => queue_name).ordered
19
19
  end
20
20
 
21
21
  it "defines a queue and binds it to its name and the given routing keys" do
@@ -28,8 +28,8 @@ shared_examples :client do
28
28
  let(:options) { {:durable => true} }
29
29
 
30
30
  before do
31
- channel.should_receive(:direct)
32
- .with(QueueingRabbit.amqp_exchange_name,
31
+ channel.should_receive(:direct).
32
+ with(QueueingRabbit.amqp_exchange_name,
33
33
  QueueingRabbit.amqp_exchange_options.merge(options))
34
34
  end
35
35
 
@@ -42,8 +42,8 @@ describe QueueingRabbit::Client::AMQP do
42
42
  end
43
43
 
44
44
  it 'triggers :event_machine_started event' do
45
- QueueingRabbit.should_receive(:trigger_event)
46
- .with(:event_machine_started)
45
+ QueueingRabbit.should_receive(:trigger_event).
46
+ with(:event_machine_started)
47
47
  subject.run_event_machine
48
48
  end
49
49
  end
@@ -51,8 +51,8 @@ describe QueueingRabbit::Client::AMQP do
51
51
 
52
52
  describe ".connect" do
53
53
  before do
54
- AMQP.should_receive(:connect).with(QueueingRabbit.amqp_uri)
55
- .and_return(connection)
54
+ AMQP.should_receive(:connect).with(QueueingRabbit.amqp_uri).
55
+ and_return(connection)
56
56
  subject.should_receive(:run_event_machine)
57
57
  end
58
58
 
@@ -98,10 +98,10 @@ describe QueueingRabbit::Client::AMQP do
98
98
  let(:payload) { JSON.dump(data) }
99
99
 
100
100
  before do
101
- client.should_receive(:define_queue).with(channel, queue_name, options)
102
- .and_return(queue)
103
- queue.should_receive(:subscribe).with(:ack => true)
104
- .and_yield(metadata, payload)
101
+ client.should_receive(:define_queue).
102
+ with(channel, queue_name, options).and_return(queue)
103
+ queue.should_receive(:subscribe).
104
+ with(:ack => true).and_yield(metadata, payload)
105
105
  end
106
106
 
107
107
  it 'listens to the queue and passes deserialized arguments to the block' do
@@ -123,8 +123,8 @@ describe QueueingRabbit::Client::AMQP do
123
123
  end
124
124
 
125
125
  it "silences JSON errors" do
126
- expect { client.listen_queue(channel, queue_name, options) }
127
- .to_not raise_error(error)
126
+ expect { client.listen_queue(channel, queue_name, options) }.
127
+ to_not raise_error(error)
128
128
  end
129
129
  end
130
130
  end
@@ -139,7 +139,7 @@ describe QueueingRabbit::Client::AMQP do
139
139
  end
140
140
 
141
141
  it "silences all errors risen" do
142
- expect {
142
+ expect {
143
143
  client.process_message(arguments) { |a| raise StandardError.new }
144
144
  }.to_not raise_error(StandardError)
145
145
  end
@@ -176,11 +176,11 @@ describe QueueingRabbit::Client::AMQP do
176
176
  let(:open_ok) { mock }
177
177
 
178
178
  before do
179
- AMQP::Channel.should_receive(:next_channel_id)
180
- .and_return(next_channel_id)
181
- AMQP::Channel.should_receive(:new)
182
- .with(connection, next_channel_id, options)
183
- .and_yield(channel, open_ok)
179
+ AMQP::Channel.should_receive(:next_channel_id).
180
+ and_return(next_channel_id)
181
+ AMQP::Channel.should_receive(:new).
182
+ with(connection, next_channel_id, options).
183
+ and_yield(channel, open_ok)
184
184
  channel.should_receive(:on_error)
185
185
  end
186
186
 
@@ -14,8 +14,8 @@ describe QueueingRabbit::Client::Bunny do
14
14
 
15
15
  describe '.connect' do
16
16
  before do
17
- Bunny.should_receive(:new).with(QueueingRabbit.amqp_uri)
18
- .and_return(connection)
17
+ Bunny.should_receive(:new).with(QueueingRabbit.amqp_uri).
18
+ and_return(connection)
19
19
  end
20
20
 
21
21
  it "instantiates an instance of itself" do
@@ -27,8 +27,8 @@ describe QueueingRabbit::Worker do
27
27
  end
28
28
 
29
29
  it 'raises JobNotPresentError' do
30
- expect { subject.new() }
31
- .to raise_error(QueueingRabbit::JobNotPresentError)
30
+ expect { subject.new() }.
31
+ to raise_error(QueueingRabbit::JobNotPresentError)
32
32
  end
33
33
  end
34
34
 
@@ -40,8 +40,8 @@ describe QueueingRabbit::Worker do
40
40
  end
41
41
 
42
42
  it 'raises JobNotFoundError' do
43
- expect { subject.new(nonexistent_class_name) }
44
- .to raise_error(QueueingRabbit::JobNotFoundError)
43
+ expect { subject.new(nonexistent_class_name) }.
44
+ to raise_error(QueueingRabbit::JobNotFoundError)
45
45
  end
46
46
  end
47
47
 
@@ -51,9 +51,9 @@ describe QueueingRabbit::Worker do
51
51
  it { should be }
52
52
  it { should respond_to(:jobs) }
53
53
  it 'changes used client to asynchronous' do
54
- expect { creation.call }.to change { QueueingRabbit.client.to_s }
55
- .from(QueueingRabbit::Client::Bunny.to_s)
56
- .to(QueueingRabbit::Client::AMQP.to_s)
54
+ expect { creation.call }.to change { QueueingRabbit.client.to_s }.
55
+ from(QueueingRabbit::Client::Bunny.to_s).
56
+ to(QueueingRabbit::Client::AMQP.to_s)
57
57
  end
58
58
  end
59
59
  end
@@ -88,8 +88,8 @@ describe QueueingRabbit::Worker do
88
88
 
89
89
  describe '#work!' do
90
90
  before do
91
- QueueingRabbit::Client::AMQP
92
- .should_receive(:join_event_machine_thread)
91
+ QueueingRabbit::Client::AMQP.
92
+ should_receive(:join_event_machine_thread)
93
93
  end
94
94
 
95
95
  it 'runs #work and joins the eventmachine thread' do
@@ -40,8 +40,8 @@ describe QueueingRabbit do
40
40
 
41
41
  before do
42
42
  subject.instance_variable_set(:@connection, connection)
43
- connection.should_receive(:open_channel).with(channel_options)
44
- .and_yield(channel, nil)
43
+ connection.should_receive(:open_channel).with(channel_options).
44
+ and_yield(channel, nil)
45
45
  connection.should_receive(:define_queue).with(channel,
46
46
  queue_name,
47
47
  queue_options)
@@ -70,12 +70,11 @@ describe QueueingRabbit do
70
70
 
71
71
  before do
72
72
  subject.instance_variable_set(:@connection, connection)
73
- connection.should_receive(:open_channel).with(channel_options)
74
- .and_yield(channel, nil)
75
- connection.should_receive(:define_queue).with(channel,
76
- queue_name,
77
- queue_options)
78
- .and_return(queue)
73
+ connection.should_receive(:open_channel).with(channel_options).
74
+ and_yield(channel, nil)
75
+ connection.should_receive(:define_queue).
76
+ with(channel, queue_name, queue_options).
77
+ and_return(queue)
79
78
  connection.should_receive(:queue_size).with(queue).and_return(size)
80
79
  end
81
80
 
@@ -89,12 +88,10 @@ describe QueueingRabbit do
89
88
 
90
89
  before do
91
90
  subject.instance_variable_set(:@connection, connection)
92
- connection.should_receive(:open_channel).with(channel_options)
93
- .and_yield(channel, nil)
94
- connection.should_receive(:define_queue).with(channel,
95
- queue_name,
96
- queue_options)
97
- .and_return(queue)
91
+ connection.should_receive(:open_channel).
92
+ with(channel_options).and_yield(channel, nil)
93
+ connection.should_receive(:define_queue).
94
+ with(channel, queue_name, queue_options).and_return(queue)
98
95
  queue.should_receive(:purge).and_return(true)
99
96
  end
100
97
 
metadata CHANGED
@@ -1,90 +1,100 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: queueing_rabbit
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 710522237
5
5
  prerelease: 6
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ - rc
11
+ - 2
12
+ version: 0.1.0.rc2
6
13
  platform: ruby
7
- authors:
14
+ authors:
8
15
  - Artem Chistyakov
9
16
  autorequire:
10
17
  bindir: bin
11
18
  cert_chain: []
12
- date: 2013-03-21 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
19
+
20
+ date: 2013-03-22 00:00:00 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
15
23
  name: amqp
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 0.9.0
22
- type: :runtime
23
24
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
+ type: :runtime
26
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
27
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 59
32
+ segments:
33
+ - 0
34
+ - 9
35
+ - 0
29
36
  version: 0.9.0
30
- - !ruby/object:Gem::Dependency
37
+ requirement: *id001
38
+ - !ruby/object:Gem::Dependency
31
39
  name: bunny
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 0.9.0.pre7
38
- type: :runtime
39
40
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
+ type: :runtime
42
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
43
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ hash: -1907877288
48
+ segments:
49
+ - 0
50
+ - 9
51
+ - 0
52
+ - pre
53
+ - 7
45
54
  version: 0.9.0.pre7
46
- - !ruby/object:Gem::Dependency
55
+ requirement: *id002
56
+ - !ruby/object:Gem::Dependency
47
57
  name: rake
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
58
+ prerelease: false
54
59
  type: :runtime
60
+ version_requirements: &id003 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ requirement: *id003
70
+ - !ruby/object:Gem::Dependency
71
+ name: json
55
72
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
73
+ type: :runtime
74
+ version_requirements: &id004 !ruby/object:Gem::Requirement
57
75
  none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- description: ! " QueueingRabbit is a Ruby library providing convenient object-oriented
63
- syntax\n for managing background jobs using AMQP. All jobs' argumets are serialized\n
64
- \ to JSON and transfered to jobs using AMQP message payload. The library\n implements
65
- amqp and bunny gems as adapters making it possible to use\n synchronous publishing
66
- and asynchronous consuming, which might be useful for\n Rails app running on
67
- non-EventMachine based application servers (i. e.\n Passenger).\n\n Any Ruby
68
- class or Module can be transformed into QueueingRabbit's background\n job by
69
- including QueueingRabbit::Job module. It is also possible to inherit\n your class
70
- from QueueingRabbit::AbstractJob abstract class.\n\n The library is bundled with
71
- a Rake task which is capable of starting a\n worker processing a specified list
72
- of jobs.\n\n To achieve the required simplicity the gem doesn't try to support
73
- all\n features of AMQP protocol. It uses a restricted subset instead:\n\n *
74
- Only a single direct exchange is used\n * Every job is consumed using a separate
75
- channel\n * All jobs are consumed with acknowledgements\n * ACK is only sent
76
- to the broker if a job was processed successfully\n * Currently all messages
77
- are published with persistent option\n"
78
- email:
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ hash: 3
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ requirement: *id004
84
+ description: " QueueingRabbit is a Ruby library providing convenient object-oriented syntax\n for managing background jobs using AMQP. All jobs' argumets are serialized\n to JSON and transfered to jobs using AMQP message payload. The library\n implements amqp and bunny gems as adapters making it possible to use\n synchronous publishing and asynchronous consuming, which might be useful for\n Rails app running on non-EventMachine based application servers (i. e.\n Passenger).\n\n Any Ruby class or Module can be transformed into QueueingRabbit's background\n job by including QueueingRabbit::Job module. It is also possible to inherit\n your class from QueueingRabbit::AbstractJob abstract class.\n\n The library is bundled with a Rake task which is capable of starting a\n worker processing a specified list of jobs.\n\n To achieve the required simplicity the gem doesn't try to support all\n features of AMQP protocol. It uses a restricted subset instead:\n\n * Only a single direct exchange is used\n * Every job is consumed using a separate channel\n * All jobs are consumed with acknowledgements\n * ACK is only sent to the broker if a job was processed successfully\n * Currently all messages are published with persistent option\n"
85
+ email:
79
86
  - chistyakov.artem@gmail.com
80
87
  executables: []
88
+
81
89
  extensions: []
82
- extra_rdoc_files:
90
+
91
+ extra_rdoc_files:
83
92
  - LICENSE
84
93
  - README.md
85
- files:
94
+ files:
86
95
  - .gitignore
87
96
  - .rvmrc
97
+ - .travis.yml
88
98
  - Gemfile
89
99
  - LICENSE
90
100
  - README.md
@@ -95,6 +105,7 @@ files:
95
105
  - lib/queueing_rabbit/client/bunny.rb
96
106
  - lib/queueing_rabbit/client/callbacks.rb
97
107
  - lib/queueing_rabbit/configuration.rb
108
+ - lib/queueing_rabbit/extensions/new_relic.rb
98
109
  - lib/queueing_rabbit/job.rb
99
110
  - lib/queueing_rabbit/logging.rb
100
111
  - lib/queueing_rabbit/serializer.rb
@@ -122,33 +133,40 @@ files:
122
133
  - spec/unit/queueing_rabbit_spec.rb
123
134
  homepage: https://github.com/temochka/queueing_rabbit
124
135
  licenses: []
136
+
125
137
  post_install_message:
126
- rdoc_options:
138
+ rdoc_options:
127
139
  - --charset=UTF-8
128
- require_paths:
140
+ require_paths:
129
141
  - lib
130
- required_ruby_version: !ruby/object:Gem::Requirement
142
+ required_ruby_version: !ruby/object:Gem::Requirement
131
143
  none: false
132
- requirements:
133
- - - ! '>='
134
- - !ruby/object:Gem::Version
135
- version: '0'
136
- segments:
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ hash: 3
148
+ segments:
137
149
  - 0
138
- hash: 1045735451665817642
139
- required_rubygems_version: !ruby/object:Gem::Requirement
150
+ version: "0"
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
152
  none: false
141
- requirements:
142
- - - ! '>'
143
- - !ruby/object:Gem::Version
153
+ requirements:
154
+ - - ">"
155
+ - !ruby/object:Gem::Version
156
+ hash: 25
157
+ segments:
158
+ - 1
159
+ - 3
160
+ - 1
144
161
  version: 1.3.1
145
162
  requirements: []
163
+
146
164
  rubyforge_project:
147
- rubygems_version: 1.8.25
165
+ rubygems_version: 1.8.24
148
166
  signing_key:
149
167
  specification_version: 3
150
168
  summary: QueueingRabbit is an AMQP-based queueing system
151
- test_files:
169
+ test_files:
152
170
  - spec/integration/asynchronous_publishing_and_consuming_spec.rb
153
171
  - spec/integration/jobs/print_line_job.rb
154
172
  - spec/integration/synchronous_publishing_and_asynchronous_consuming_spec.rb