twingly-amqp 4.4.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afa12f0f296e62925302731fdcf55c620ef593536340455b757e18168e6d76b7
4
- data.tar.gz: 0545a905095cb041cd1f91556b4ba868444c2c25d27117079f73a4ee8c6d0ad4
3
+ metadata.gz: 7551c367b84090b3f0e7345ef8b24128983e194074bea558e3595aeaf7d846ce
4
+ data.tar.gz: 8c633747ce2675338de1ac65eb7b67e21e3f39ce036351482736653a1755a597
5
5
  SHA512:
6
- metadata.gz: c7c2e089cf8cd98f78706bb5e7dcbde5da880374d3d1947165152312b7757d34eef36de279031af3cd6e7662a0bef06a4ad8ca98936a99f33fafecd0e8bc2e2c
7
- data.tar.gz: 12e0033eccf69edbb3e657cf67bb0486e4bab449b7acebf24c0a88b87477321d1ced6e2d5df0b10719e484841c429a17dd749f98ee2edc10565293af6f091e79
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", # Optional, uses the default exchange if omitted
59
- routing_key: "url.blog", # Optional, uses the default exchange if omitted
60
- consumer_threads: 4, # Optional
61
- prefetch: 20, # Optional
62
- max_length: 10_000, # Optional
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, connection: nil,
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
- @routing_key = routing_key
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 && @routing_key
26
+ if @exchange_topic && @routing_keys.any?
22
27
  exchange = @channel.topic(@exchange_topic, durable: true)
23
- @queue.bind(exchange, routing_key: @routing_key)
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 {}
@@ -1,5 +1,5 @@
1
1
  module Twingly
2
2
  module Amqp
3
- VERSION = "4.4.0".freeze
3
+ VERSION = "4.5.0".freeze
4
4
  end
5
5
  end
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.0
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-07-02 00:00:00.000000000 Z
11
+ date: 2018-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny