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 +4 -4
- data/lib/ElmerFudd/version.rb +1 -1
- data/lib/ElmerFudd.rb +15 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 495ca1024544a93568872748bc264f6654ba8dda
|
4
|
+
data.tar.gz: 4280d48353cb7746adf1858f7a4b274c9d765987
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc27f1148cc89102d73fb67c8fc4ad0bb3c5d9924d5e77eb66ae87acb34cc6817384ec9a1ba7be86dcd14cae5569f5889915625f2b5613640166301637dca760
|
7
|
+
data.tar.gz: 192f28497fa7a70ce86dc2746df757144e0e22ae0721a5415d793d57143f31c3bed2d6aaf767dfa315bd7da0be23181d2fd9c397260970504d7db8862eba5a7c
|
data/lib/ElmerFudd/version.rb
CHANGED
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
|
-
|
25
|
-
|
26
|
-
|
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:
|
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
|
-
|
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
|
-
|
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.
|
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-
|
12
|
+
date: 2015-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bunny
|