bunny_burrow 1.5.2 → 1.5.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9f59ed06d792f9c5984ca3e621c6a734063b1ac
4
- data.tar.gz: f750e7145b8074d481700d9a3f9358c34708363d
3
+ metadata.gz: 673a05f44f658570ba0b421d5e4592e4a6d8da47
4
+ data.tar.gz: aaa51e1e5a7c94e35e6812330092909fed493e06
5
5
  SHA512:
6
- metadata.gz: f1f51879842df68648545a61638772bbe0a2f0eae0fe051cfa424a7e4f64b7e60f4b73303e4d0100059617a63ca4074f64e241fe3085154744c9758c0a987af5
7
- data.tar.gz: 285d7516c3b13b0bff10dbfa91a2e2f5caf8e211cad92d788dd71b5748614b444391b186536e2a0259c35568501c9400acc0353b1ae56a2bcc184fcc3c8eb531
6
+ metadata.gz: 63c9fcb9eef80edb283b5be5a4b36f5e458276253b7a559da917864ebacda8de109a2f2e5b1196f0bb375e33384cdf988e37c4563160193ab70ce070488668f5
7
+ data.tar.gz: 542907ae1679ceee6196028f9c49fff90def448f76eaa368a8fb0babfc4b9fd1f5450e319640f79300cacb88f013f63a759a9a5f4a4e6ead1d021c406b708830
@@ -1,44 +1,54 @@
1
1
  require_relative 'base'
2
+ require 'securerandom'
2
3
 
3
4
  module BunnyBurrow
4
5
  class Client < Base
6
+
7
+ DIRECT_REPLY_TO = 'amq.rabbitmq.reply-to'
8
+
9
+
5
10
  def publish(payload, routing_key)
6
11
  result = nil
7
12
 
8
- # when creating a queue, a blank name indicates we want the AMPQ broker
9
- # to generate a unique name for us. Also note that this queue will be on
10
- # the default exchange
11
- reply_to = channel.queue('', exclusive: true, auto_delete: true)
12
-
13
13
  details = {
14
14
  routing_key: routing_key,
15
- reply_to: reply_to
15
+ reply_to: DIRECT_REPLY_TO
16
16
  }
17
+
17
18
  details[:request] = payload if log_request?
18
19
  log "Publishing #{details}"
19
20
 
20
21
  options = {
21
22
  routing_key: routing_key,
22
- reply_to: reply_to.name,
23
+ reply_to: DIRECT_REPLY_TO,
23
24
  persistence: false
24
25
  }
25
26
 
26
- topic_exchange.publish(payload.to_json, options)
27
+ consumer = Bunny::Consumer.new(channel, DIRECT_REPLY_TO, SecureRandom.uuid)
28
+ consumer.on_delivery do |_, _, received_payload|
29
+ result = handle_delivery(details, received_payload)
30
+ end
27
31
 
28
- Timeout.timeout(timeout) do
29
- reply_to.subscribe do |_, _, payload|
30
- details[:response] = payload if log_response?
31
- log "Receiving #{details}"
32
- result = payload
33
- lock.synchronize { condition.signal }
34
- end
35
32
 
36
- lock.synchronize { condition.wait(lock) }
33
+ begin
34
+ channel.basic_consume_with consumer
35
+ topic_exchange.publish(payload.to_json, options)
36
+
37
+ Timeout.timeout(timeout) do
38
+ lock.synchronize {condition.wait(lock)}
39
+ end
40
+ ensure
41
+ consumer.cancel
37
42
  end
43
+ result
44
+ end
38
45
 
39
- result
40
- ensure
41
- reply_to.delete if reply_to
46
+ def handle_delivery(details, payload)
47
+ details[:response] = payload if log_response?
48
+ log "Receiving #{details}"
49
+ result = payload
50
+ lock.synchronize {condition.signal}
51
+ result
42
52
  end
43
53
  end
44
54
  end
@@ -1,3 +1,3 @@
1
1
  module BunnyBurrow
2
- VERSION = '1.5.2'
2
+ VERSION = '1.5.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny_burrow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vericity
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-19 00:00:00.000000000 Z
11
+ date: 2017-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler