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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bcc5a27e95295996a0ab83dc418d83f3de08d781
4
- data.tar.gz: b312902dc951429fac7de9b95570aedb51693dd6
3
+ metadata.gz: 24d299a3950ef9657bd34174b9c8d481a0e56fba
4
+ data.tar.gz: a727afba051f4ca4c5076079bbc249b998c8e161
5
5
  SHA512:
6
- metadata.gz: 9014cd6003a6f085b5218c68e54ef9774696a7a692408ace7e0b6334a5ad1290cb313324daa8caeec82c49639dad35fafa5cfffadb6e12748f71444f9c5fc735
7
- data.tar.gz: 15526144210be6e01019a5bf630a279cd99e2336eeb816a21a7700bc907821e9df954bd67e70dab9b831cc5becba76ad67d21731109f3bb98e91e8eacea4c472
6
+ metadata.gz: ab8b9797eb29537346aef0cd7357a9738c47e348b88fa450e7d651e837ac1726a6dfbe1c2e507714af394dcdd40479171b38c552414067ac1020001c1ae361ce
7
+ data.tar.gz: 167e6a264f36d8c364d25715fd67b0aeead8dd838b574f863c5cfed39e4cebffb37406b5e7316d982a5772420b8a7a2bdaf3e257df1123276e1cd0c1eca5322d
data/README.md CHANGED
@@ -50,4 +50,4 @@ the last block body is the return body.
50
50
 
51
51
  ## TODO
52
52
 
53
- * Time Out
53
+ * to become backend_work.
@@ -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
- @cv = ConditionVariable.new
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 { @cv.wait(@mutex) }
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 { @cv.signal }
56
+ @mutex.synchronize { @condition_variable.signal }
46
57
  end
47
58
 
48
59
  def connect
@@ -1,7 +1,5 @@
1
1
  module BunnyRpc
2
2
  class Server
3
- attr_accessor :reply_correlation_id, :reply_to, :queue_name
4
-
5
3
  def initialize(options={})
6
4
  @options = options
7
5
  end
@@ -1,3 +1,3 @@
1
1
  module BunnyRpc
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny_rpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - menghuanwd