urabbit 0.1.0 → 0.1.1

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: adcc16557fc9a39bb74252719281f9d5ba85cabe
4
- data.tar.gz: d74ecf49a85e96b09b9926608ed3240983096616
3
+ metadata.gz: 75cd5cf7a7a2c13f4f848c30649f2c6af97af9eb
4
+ data.tar.gz: 07941cff03f8c709c0b61f16d4de5e9b4e9283ad
5
5
  SHA512:
6
- metadata.gz: bab9f320bbd2e39e5bc4276bf7a185dd93276c9cdef05f1b12a9a407e09c7233cde9d97427c9801713ad79510f0f4e4352f19db392df441b72ee467a69f43700
7
- data.tar.gz: 3675a9c90aab6927d38200bba95ff7e5785cf003441e3530efa73ba47623869ddfd1b33aa34602e8a13c8ad5983a34685ac6baf84a5a16a54363d73938ab3aa4
6
+ metadata.gz: c77b3fa6a8322cf117d9b991ffe12cdd9d45f303c054773a29ed0203255cc145832d36e0791c7675bcfdfc963ac18b93d853f8c1f0ac9b411ab1cac201ee8243
7
+ data.tar.gz: 3d769d50b61b9024d6e31ccd7f4f441a87e940e88b62def4533bf4f716cdd758d724cd6c82124cfd474e832d1a203d758eb01fdf790b922c16f55305a4d5b70a
@@ -26,7 +26,12 @@ class Urabbit::Publisher
26
26
  @connection = Bunny.new(cloudamqp_url, logger: Urabbit.logger)
27
27
  @connection.start
28
28
  @channel = @connection.create_channel
29
- @exchange = Bunny::Exchange.new(@channel, exchange_type, exchange_name)
29
+ @exchange = Bunny::Exchange.new(
30
+ @channel,
31
+ exchange_type,
32
+ exchange_name,
33
+ durable: true
34
+ )
30
35
  rescue Bunny::Exception
31
36
  raise Error.new("Error connecting to queue")
32
37
  end
@@ -19,6 +19,7 @@
19
19
  # It can also contain a cause raised from Bunny itself.
20
20
  class Urabbit::RPC::Client
21
21
  class Error < Exception; end
22
+ class ServerError < Error; end
22
23
 
23
24
  def initialize(cloudamqp_url = ENV["CLOUDAMQP_URL"])
24
25
  @connection = Bunny.new(cloudamqp_url, logger: Urabbit.logger)
@@ -59,11 +60,12 @@ class Urabbit::RPC::Client
59
60
  @lock.synchronize{@condition.wait(@lock, timeout)}
60
61
 
61
62
  if @error.nil? && @result.nil?
62
- raise Error.new("Timed out waiting for reply")
63
+ raise Error.new("Timed out waiting for reply. "\
64
+ "Make sure the RPC queue name is correct.")
63
65
  end
64
66
 
65
67
  if @error
66
- raise Error.new(@error['message'])
68
+ raise ServerError.new(@error['message'])
67
69
  else
68
70
  @result
69
71
  end
@@ -17,7 +17,7 @@ module Urabbit::RPC::Server
17
17
  @queue = @channel.queue(self.class.queue_name)
18
18
  @exchange = @channel.default_exchange
19
19
 
20
- @queue.subscribe(block: true) do |delivery_info, properties, payload|
20
+ @queue.subscribe do |delivery_info, properties, payload|
21
21
  begin
22
22
  result = work(payload)
23
23
 
@@ -39,6 +39,10 @@ module Urabbit::RPC::Server
39
39
  end
40
40
  end
41
41
 
42
+ # Subscribing in blocking mode above disables auto-reconnection feature.
43
+ # It's better to just sleep.
44
+ sleep
45
+
42
46
  logger.info("Stopped responding to RPC calls for #{self.class.name}")
43
47
  end
44
48
 
@@ -1,3 +1,3 @@
1
1
  module Urabbit
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urabbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacek Becela