bunny_rpc 0.1.3 → 0.1.4
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 +1 -1
- data/lib/bunny_rpc/client.rb +16 -5
- data/lib/bunny_rpc/server.rb +0 -2
- data/lib/bunny_rpc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24d299a3950ef9657bd34174b9c8d481a0e56fba
|
4
|
+
data.tar.gz: a727afba051f4ca4c5076079bbc249b998c8e161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab8b9797eb29537346aef0cd7357a9738c47e348b88fa450e7d651e837ac1726a6dfbe1c2e507714af394dcdd40479171b38c552414067ac1020001c1ae361ce
|
7
|
+
data.tar.gz: 167e6a264f36d8c364d25715fd67b0aeead8dd838b574f863c5cfed39e4cebffb37406b5e7316d982a5772420b8a7a2bdaf3e257df1123276e1cd0c1eca5322d
|
data/README.md
CHANGED
data/lib/bunny_rpc/client.rb
CHANGED
@@ -2,12 +2,12 @@ require 'bunny'
|
|
2
2
|
|
3
3
|
module BunnyRpc
|
4
4
|
class Client
|
5
|
-
attr_reader :payload, :correlation_id
|
6
|
-
|
7
5
|
def initialize(options={})
|
8
6
|
@options = options
|
9
7
|
@mutex = Mutex.new
|
10
|
-
@
|
8
|
+
@timeout = options[:timeout] || 5
|
9
|
+
@condition_variable = ConditionVariable.new
|
10
|
+
@correlation_id = correlation_id
|
11
11
|
end
|
12
12
|
|
13
13
|
def publish(body, queue_name)
|
@@ -38,11 +38,22 @@ module BunnyRpc
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def add_lock
|
41
|
-
@mutex.synchronize
|
41
|
+
@mutex.synchronize do
|
42
|
+
expire_time = Time.now + @timeout
|
43
|
+
loop do
|
44
|
+
if @payload.nil?
|
45
|
+
remaining = expire_time - Time.now
|
46
|
+
raise(Timeout::Error, "Waited #{@timeout} seconds") if(remaining <= 0)
|
47
|
+
else
|
48
|
+
@condition_variable.wait(@mutex, remaining)
|
49
|
+
return
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
42
53
|
end
|
43
54
|
|
44
55
|
def del_lock
|
45
|
-
@mutex.synchronize { @
|
56
|
+
@mutex.synchronize { @condition_variable.signal }
|
46
57
|
end
|
47
58
|
|
48
59
|
def connect
|
data/lib/bunny_rpc/server.rb
CHANGED
data/lib/bunny_rpc/version.rb
CHANGED