ElmerFudd 0.0.22 → 0.0.24

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
  SHA1:
3
- metadata.gz: 4c1b4a8df99cde4543eab1c5bc3e49bdb5fe64b1
4
- data.tar.gz: aca2e2f7a8f945024f0e70758a68b6a25c0ef414
3
+ metadata.gz: 495ca1024544a93568872748bc264f6654ba8dda
4
+ data.tar.gz: 4280d48353cb7746adf1858f7a4b274c9d765987
5
5
  SHA512:
6
- metadata.gz: 6ea1a8c610dbb0fcfa2e2580837a6c900e9544c71d965ff8a9cd30dd956b5d21f566316bccd34d854ecae80b12129158746485fca4b4abb9b7245b203ad63c27
7
- data.tar.gz: 92cd593f028b61e16ed921821b8b3917eabd797f00fe7be75b275d5639b76df3e353085aae441e873c63d6172bc38184d0bd1943f5457f9e6802d0cc836a07ba
6
+ metadata.gz: cc27f1148cc89102d73fb67c8fc4ad0bb3c5d9924d5e77eb66ae87acb34cc6817384ec9a1ba7be86dcd14cae5569f5889915625f2b5613640166301637dca760
7
+ data.tar.gz: 192f28497fa7a70ce86dc2746df757144e0e22ae0721a5415d793d57143f31c3bed2d6aaf767dfa315bd7da0be23181d2fd9c397260970504d7db8862eba5a7c
@@ -1,3 +1,3 @@
1
1
  module ElmerFudd
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.24"
3
3
  end
data/lib/ElmerFudd.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "ElmerFudd/version"
2
2
  require "bunny"
3
+ require "thread"
3
4
 
4
5
  module ElmerFudd
5
6
  class Publisher
@@ -21,22 +22,28 @@ module ElmerFudd
21
22
  end
22
23
 
23
24
  def call(queue_name, payload, timeout: 10)
24
- x.publish(payload.to_s, routing_key: queue_name, reply_to: rpc_reply_queue.name,
25
- correlation_id: correlation_id = @uuid_service.call)
26
- response = nil
25
+ mutex = Mutex.new
26
+ resource = ConditionVariable.new
27
+ correlation_id = @uuid_service.call
27
28
  consumer_tag = @uuid_service.call
29
+ response = nil
30
+
28
31
  Timeout.timeout(timeout) do
29
- rpc_reply_queue.subscribe(manual_ack: false, block: true, consumer_tag: consumer_tag) do |delivery_info, properties, payload|
32
+ rpc_reply_queue.subscribe(manual_ack: false, block: false, consumer_tag: consumer_tag) do |delivery_info, properties, payload|
30
33
  if properties[:correlation_id] == correlation_id
31
34
  response = payload
32
- delivery_info.consumer.cancel
35
+ mutex.synchronize { resource.signal }
33
36
  end
34
37
  end
38
+
39
+ x.publish(payload.to_s, routing_key: queue_name, reply_to: rpc_reply_queue.name,
40
+ correlation_id: correlation_id)
41
+
42
+ mutex.synchronize { resource.wait(mutex) unless response }
43
+ response
35
44
  end
36
- response
37
- rescue Timeout::Error
45
+ ensure
38
46
  reply_channel.consumers[consumer_tag].cancel
39
- raise
40
47
  end
41
48
 
42
49
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ElmerFudd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrzej Sliwa
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-16 00:00:00.000000000 Z
12
+ date: 2015-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bunny