queueing_rabbit 0.3.10 → 0.4.0
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/README.md +62 -13
- data/lib/queueing_rabbit/version.rb +1 -1
- data/queueing_rabbit.gemspec +6 -8
- metadata +13 -16
data/README.md
CHANGED
@@ -1,16 +1,66 @@
|
|
1
1
|
# QueueingRabbit [](https://travis-ci.org/temochka/queueing_rabbit) [](https://codeclimate.com/github/temochka/queueing_rabbit)
|
2
2
|
|
3
|
-
QueueingRabbit
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
QueueingRabbit provides a Ruby DSL to interact with RabbitMQ. It is fairly flexible and allows you to integrate with existing infrastructure and naming conventions. It currently offers gems [bunny](https://github.com/ruby-amqp/bunny) and [amqp](https://github.com/ruby-amqp/amqp) as supported back-ends.
|
4
|
+
|
5
|
+
## Example
|
6
|
+
|
7
|
+
The following Ruby program publishes an excerpt of Joseph Brodsky’s poem line by line to a RabbitMQ exchange and prints received messages on the screen.
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
require 'queueing_rabbit'
|
11
|
+
|
12
|
+
class Reciter < QueueingRabbit::AbstractJob
|
13
|
+
|
14
|
+
def perform
|
15
|
+
puts payload
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
worker = QueueingRabbit::Worker.new(Reciter)
|
21
|
+
|
22
|
+
poem = <<-
|
23
|
+
I said fate plays a game without a score,
|
24
|
+
and who needs fish if you've got caviar?
|
25
|
+
The triumph of the Gothic style would come to pass
|
26
|
+
and turn you on - no need for coke, or grass.
|
27
|
+
I sit by the window. Outside, an aspen.
|
28
|
+
When I loved, I loved deeply. It wasn't often.
|
29
|
+
|
30
|
+
|
31
|
+
Thread.new {
|
32
|
+
poem.each_line { |l| Reciter.enqueue(l) }
|
33
|
+
sleep 5
|
34
|
+
worker.stop
|
35
|
+
}
|
36
|
+
|
37
|
+
worker.work!
|
38
|
+
```
|
39
|
+
|
40
|
+
This code has following important side effects:
|
41
|
+
|
42
|
+
* A Rabbit queue named `Reciter` is created with default options (if not exists).
|
43
|
+
* 6 messages are published to the default exchange with routing key `Reciter`.
|
44
|
+
* 6 messages are consumed from the `Reciter` queue.
|
45
|
+
* 6 lines of the poem are printed to STDOUT.
|
46
|
+
|
47
|
+
## Choosing the back-end: bunny or amqp?
|
48
|
+
|
49
|
+
`Bunny` is a pseudo-synchronous RabbitMQ client. `Amqp` is EventMachine-based and heavily asynchronous (lots of callbacks involved). Both clients are in active development, thoroughly documented and fairly stable.
|
50
|
+
|
51
|
+
Choose `bunny` if you don’t want to worry about blocking I/O and EventMachine-compilant drivers. Choose `amqp` if you’re familiar with EventMachine, designing a lightweight app from scratch and performance is a serious concern. Obviously there are exceptions, and no one knows your requirements better than you.
|
52
|
+
|
53
|
+
Also, you can use both of them. For example, you may decide to publish via `bunny` from your Rails app and use `amqp` in your background worker.
|
54
|
+
|
55
|
+
## Documentation & Support
|
56
|
+
|
57
|
+
Check out the [project wiki](https://github.com/temochka/queueing_rabbit/wiki) for additional guidance. If you have questions or something doesn’t work for you, feel free to file issues.
|
10
58
|
|
11
59
|
## Installation
|
12
60
|
|
13
|
-
|
61
|
+
QueueingRabbit supports MRI Ruby version 1.9.3 and above. It is still compilant with Ruby 1.8.7, but some features may not work as expected and the compatibility will be removed in the near future.
|
62
|
+
|
63
|
+
Add this line to your application's `Gemfile`:
|
14
64
|
|
15
65
|
gem 'queueing_rabbit'
|
16
66
|
|
@@ -18,16 +68,15 @@ And then execute:
|
|
18
68
|
|
19
69
|
$ bundle
|
20
70
|
|
21
|
-
Or install it
|
71
|
+
Or install it globally as:
|
22
72
|
|
23
73
|
$ gem install queueing_rabbit
|
24
74
|
|
25
|
-
## Usage
|
26
75
|
|
27
|
-
|
76
|
+
## Special Thanks
|
28
77
|
|
29
|
-
|
30
|
-
|
78
|
+
* [Wildbit](http://wildbit.com) — for letting me open source this library initially developed for the internal use.
|
79
|
+
* [RabbitMQ client libraries for Ruby](https://github.com/ruby-amqp) — for providing outstanding well-documented gems that made this project possible.
|
31
80
|
|
32
81
|
## Contributing
|
33
82
|
|
data/queueing_rabbit.gemspec
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/queueing_rabbit/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Artem Chistyakov"]
|
6
6
|
gem.email = ["chistyakov.artem@gmail.com"]
|
7
|
-
gem.summary = %q{QueueingRabbit
|
7
|
+
gem.summary = %q{QueueingRabbit provides a flexible DSL to interact with RabbitMQ}
|
8
8
|
gem.homepage = "https://github.com/temochka/queueing_rabbit"
|
9
9
|
|
10
10
|
gem.files = `git ls-files`.split($\)
|
@@ -13,6 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.name = "queueing_rabbit"
|
14
14
|
gem.require_paths = ["lib"]
|
15
15
|
gem.version = QueueingRabbit::VERSION
|
16
|
+
gem.license = 'MIT'
|
16
17
|
|
17
18
|
gem.extra_rdoc_files = [ "LICENSE", "README.md" ]
|
18
19
|
gem.rdoc_options = ["--charset=UTF-8"]
|
@@ -23,17 +24,14 @@ Gem::Specification.new do |gem|
|
|
23
24
|
gem.add_dependency "json", ">= 0"
|
24
25
|
|
25
26
|
gem.description = <<description
|
26
|
-
QueueingRabbit is a Ruby library providing
|
27
|
-
|
28
|
-
bunny gems as adapters making it possible to use synchronous publishing and
|
29
|
-
asynchronous consuming, which might be useful for Rails app running on
|
30
|
-
non-EventMachine based application servers (i. e. Passenger).
|
27
|
+
QueueingRabbit is a Ruby library providing a flexible DSL to interact with a
|
28
|
+
RabbitMQ server.
|
31
29
|
|
32
30
|
Any Ruby class or Module can be transformed into QueueingRabbit's background
|
33
31
|
job by including QueueingRabbit::Job module. It is also possible to inherit
|
34
32
|
your class from QueueingRabbit::AbstractJob abstract class.
|
35
33
|
|
36
|
-
The library is bundled with a Rake task
|
37
|
-
|
34
|
+
The library is bundled with a Rake task to start a worker processing a list
|
35
|
+
of specified jobs.
|
38
36
|
description
|
39
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queueing_rabbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: amqp
|
@@ -75,16 +75,12 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
-
description: ! " QueueingRabbit is a Ruby library providing
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
\
|
83
|
-
|
84
|
-
including QueueingRabbit::Job module. It is also possible to inherit\n your class
|
85
|
-
from QueueingRabbit::AbstractJob abstract class.\n\n The library is bundled with
|
86
|
-
a Rake task which is capable of starting a\n worker processing a specified list
|
87
|
-
of jobs.\n"
|
78
|
+
description: ! " QueueingRabbit is a Ruby library providing a flexible DSL to interact
|
79
|
+
with a\n RabbitMQ server.\n\n Any Ruby class or Module can be transformed
|
80
|
+
into QueueingRabbit's background\n job by including QueueingRabbit::Job module.
|
81
|
+
It is also possible to inherit\n your class from QueueingRabbit::AbstractJob
|
82
|
+
abstract class.\n\n The library is bundled with a Rake task to start a worker
|
83
|
+
processing a list\n of specified jobs.\n"
|
88
84
|
email:
|
89
85
|
- chistyakov.artem@gmail.com
|
90
86
|
executables: []
|
@@ -160,7 +156,8 @@ files:
|
|
160
156
|
- spec/unit/queueing_rabbit/worker_spec.rb
|
161
157
|
- spec/unit/queueing_rabbit_spec.rb
|
162
158
|
homepage: https://github.com/temochka/queueing_rabbit
|
163
|
-
licenses:
|
159
|
+
licenses:
|
160
|
+
- MIT
|
164
161
|
post_install_message:
|
165
162
|
rdoc_options:
|
166
163
|
- --charset=UTF-8
|
@@ -174,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
171
|
version: '0'
|
175
172
|
segments:
|
176
173
|
- 0
|
177
|
-
hash:
|
174
|
+
hash: 3856307769293124515
|
178
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
176
|
none: false
|
180
177
|
requirements:
|
@@ -183,13 +180,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
180
|
version: '0'
|
184
181
|
segments:
|
185
182
|
- 0
|
186
|
-
hash:
|
183
|
+
hash: 3856307769293124515
|
187
184
|
requirements: []
|
188
185
|
rubyforge_project:
|
189
186
|
rubygems_version: 1.8.23
|
190
187
|
signing_key:
|
191
188
|
specification_version: 3
|
192
|
-
summary: QueueingRabbit
|
189
|
+
summary: QueueingRabbit provides a flexible DSL to interact with RabbitMQ
|
193
190
|
test_files:
|
194
191
|
- spec/integration/asynchronous_batch_publishing_spec.rb
|
195
192
|
- spec/integration/asynchronous_publishing_and_consuming_spec.rb
|