rt-tackle 1.1.1 → 1.1.2
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/README.md +16 -0
- data/lib/tackle/connection.rb +3 -2
- data/lib/tackle/consumer/params.rb +3 -0
- data/lib/tackle/consumer.rb +1 -1
- data/lib/tackle/publisher.rb +3 -2
- data/lib/tackle/version.rb +1 -1
- data/lib/tackle.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63bc52d4f711f20e99c10694d51a721971263931
|
4
|
+
data.tar.gz: 90c678ff964a4e1e9a0c162f1dd539951cf8bf9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06e85b388d9d887761b89f32a4024bc85d0fc497f0189b16d023fa4dbdc48bd1958f84b780ff18b91215fa03977ffb385ed7fa380e581018d1ccd1e3419f5fb7
|
7
|
+
data.tar.gz: 863b47df45b8f0a38e583ddd2a3dd89b4c3f91c6489b43af27d5f7b4cca1ab5f6889088bff08c176bea54cd6b3aff3c903da3f7d6793eaa2c8dccaa950bbd72f
|
data/README.md
CHANGED
@@ -192,6 +192,22 @@ end
|
|
192
192
|
If neither Tackle::ACK nor Tackle::NACK are returned, tackle assumes
|
193
193
|
that the response is negative.
|
194
194
|
|
195
|
+
## Test
|
196
|
+
|
197
|
+
To better performance in unit test put a instance mock of Bunny class in a
|
198
|
+
connection key at options, for example, you could use a gem bunny-mock.
|
199
|
+
|
200
|
+
```ruby
|
201
|
+
|
202
|
+
options = {
|
203
|
+
:url => "amqp://localhost",
|
204
|
+
...
|
205
|
+
:connection => BunnyMock.new
|
206
|
+
...
|
207
|
+
}
|
208
|
+
|
209
|
+
```
|
210
|
+
|
195
211
|
## Development
|
196
212
|
|
197
213
|
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
data/lib/tackle/connection.rb
CHANGED
@@ -2,10 +2,11 @@ module Tackle
|
|
2
2
|
class Connection
|
3
3
|
attr_reader :channel
|
4
4
|
|
5
|
-
def initialize(amqp_url, exception_handler, logger)
|
5
|
+
def initialize(amqp_url, exception_handler, logger, connection = nil)
|
6
6
|
@amqp_url = amqp_url
|
7
7
|
@exception_handler = exception_handler
|
8
8
|
@logger = logger
|
9
|
+
@connection = connection
|
9
10
|
|
10
11
|
connect
|
11
12
|
end
|
@@ -13,7 +14,7 @@ module Tackle
|
|
13
14
|
def connect
|
14
15
|
@logger.info("Connecting to RabbitMQ")
|
15
16
|
|
16
|
-
@connection
|
17
|
+
@connection ||= Bunny.new(@amqp_url)
|
17
18
|
@connection.start
|
18
19
|
|
19
20
|
@logger.info("Connected to RabbitMQ")
|
@@ -11,6 +11,7 @@ module Tackle
|
|
11
11
|
attr_reader :logger
|
12
12
|
attr_reader :exception_handler
|
13
13
|
attr_reader :manual_ack
|
14
|
+
attr_reader :connection
|
14
15
|
|
15
16
|
def initialize(params = {})
|
16
17
|
# required
|
@@ -26,6 +27,8 @@ module Tackle
|
|
26
27
|
@manual_ack = params.fetch(:manual_ack, false)
|
27
28
|
|
28
29
|
@exception_handler = params[:exception_handler]
|
30
|
+
|
31
|
+
@connection = params.fetch(:connection, nil)
|
29
32
|
end
|
30
33
|
|
31
34
|
def manual_ack?
|
data/lib/tackle/consumer.rb
CHANGED
@@ -18,7 +18,7 @@ module Tackle
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def setup_rabbit_connections
|
21
|
-
@connection = Tackle::Connection.new(@params.amqp_url, @params.exception_handler, @logger)
|
21
|
+
@connection = Tackle::Connection.new(@params.amqp_url, @params.exception_handler, @logger, @params.connection)
|
22
22
|
|
23
23
|
@exchange = Exchange.new(@params.service, @params.routing_key, @connection, @logger)
|
24
24
|
@main_queue = MainQueue.new(@exchange, @connection, @logger)
|
data/lib/tackle/publisher.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
module Tackle
|
2
2
|
class Publisher
|
3
3
|
|
4
|
-
def initialize(url, exchange_name, routing_key, logger)
|
4
|
+
def initialize(url, exchange_name, routing_key, logger, connection = nil)
|
5
5
|
@url = url
|
6
6
|
@exchange_name = exchange_name
|
7
7
|
@routing_key = routing_key
|
8
8
|
@logger = logger
|
9
|
+
@connection = connection
|
9
10
|
end
|
10
11
|
|
11
12
|
def publish(message)
|
12
|
-
connection = Tackle::Connection.new(@url, nil, @logger)
|
13
|
+
connection = Tackle::Connection.new(@url, nil, @logger, @connection)
|
13
14
|
|
14
15
|
@logger.info("Declaring exchange='#{@exchange_name}'")
|
15
16
|
exchange = connection.channel.direct(@exchange_name, :durable => true)
|
data/lib/tackle/version.rb
CHANGED
data/lib/tackle.rb
CHANGED
@@ -24,7 +24,8 @@ module Tackle
|
|
24
24
|
exchange = options.fetch(:exchange)
|
25
25
|
routing_key = options.fetch(:routing_key)
|
26
26
|
logger = options.fetch(:logger, Logger.new(STDOUT))
|
27
|
+
connection = options.fetch(:connection, nil)
|
27
28
|
|
28
|
-
Tackle::Publisher.new(url, exchange, routing_key, logger).publish(message)
|
29
|
+
Tackle::Publisher.new(url, exchange, routing_key, logger, connection).publish(message)
|
29
30
|
end
|
30
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rt-tackle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rendered Text
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
131
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.6.
|
132
|
+
rubygems_version: 2.6.14
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: RabbitMQ based single-thread worker
|