twingly-amqp 4.4.0 → 4.5.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.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/twingly/amqp/subscription.rb +13 -5
- data/lib/twingly/amqp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7551c367b84090b3f0e7345ef8b24128983e194074bea558e3595aeaf7d846ce
|
4
|
+
data.tar.gz: 8c633747ce2675338de1ac65eb7b67e21e3f39ce036351482736653a1755a597
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1838eadf2e3fec47833c1dfdbc8000bb18d0c77b3d39d30252cb4d7855f2c83bacf3ffcbc70627043da7d6b402adc95110c28cf60eef84838d49b3b075b4b84d
|
7
|
+
data.tar.gz: 17c0fa7c47552ff00832b0484dbaea894bf15ecce43c65e3d8cd1cb9abaae6717237ade7b26a77ea7daac4aa43d7ace7092de87ca2d823e0f37161b7e8cfdfbd
|
data/README.md
CHANGED
@@ -55,11 +55,11 @@ end
|
|
55
55
|
```ruby
|
56
56
|
subscription = Twingly::AMQP::Subscription.new(
|
57
57
|
queue_name: "crawler-urls",
|
58
|
-
exchange_topic: "url-exchange",
|
59
|
-
|
60
|
-
consumer_threads: 4,
|
61
|
-
prefetch: 20,
|
62
|
-
max_length: 10_000,
|
58
|
+
exchange_topic: "url-exchange", # Optional, uses the default exchange if omitted
|
59
|
+
routing_keys: %w(url.blog url.post), # Optional, uses the default exchange if omitted
|
60
|
+
consumer_threads: 4, # Optional
|
61
|
+
prefetch: 20, # Optional
|
62
|
+
max_length: 10_000, # Optional
|
63
63
|
)
|
64
64
|
|
65
65
|
subscription.on_exception { |exception| puts "Oh noes! #{exception.message}" }
|
@@ -5,22 +5,30 @@ module Twingly
|
|
5
5
|
module AMQP
|
6
6
|
class Subscription
|
7
7
|
def initialize(queue_name:, exchange_topic: nil, routing_key: nil,
|
8
|
-
consumer_threads: 4, prefetch: 20,
|
9
|
-
max_length: nil)
|
8
|
+
routing_keys: nil, consumer_threads: 4, prefetch: 20,
|
9
|
+
connection: nil, max_length: nil)
|
10
10
|
@queue_name = queue_name
|
11
11
|
@exchange_topic = exchange_topic
|
12
|
-
@
|
12
|
+
@routing_keys = Array(routing_keys || routing_key)
|
13
13
|
@consumer_threads = consumer_threads
|
14
14
|
@prefetch = prefetch
|
15
15
|
@max_length = max_length
|
16
16
|
|
17
|
+
if routing_key
|
18
|
+
warn "[DEPRECATION] `routing_key` is deprecated. "\
|
19
|
+
"Please use `routing_keys` instead."
|
20
|
+
end
|
21
|
+
|
17
22
|
connection ||= Connection.instance
|
18
23
|
@channel = create_channel(connection)
|
19
24
|
@queue = @channel.queue(@queue_name, queue_options)
|
20
25
|
|
21
|
-
if @exchange_topic && @
|
26
|
+
if @exchange_topic && @routing_keys.any?
|
22
27
|
exchange = @channel.topic(@exchange_topic, durable: true)
|
23
|
-
|
28
|
+
|
29
|
+
@routing_keys.each do |routing_key|
|
30
|
+
@queue.bind(exchange, routing_key: routing_key)
|
31
|
+
end
|
24
32
|
end
|
25
33
|
|
26
34
|
@before_handle_message_callback = proc {}
|
data/lib/twingly/amqp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twingly-amqp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Twingly AB
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|