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 +4 -4
- data/lib/urabbit/publisher.rb +6 -1
- data/lib/urabbit/rpc/client.rb +4 -2
- data/lib/urabbit/rpc/server.rb +5 -1
- data/lib/urabbit/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: 75cd5cf7a7a2c13f4f848c30649f2c6af97af9eb
|
4
|
+
data.tar.gz: 07941cff03f8c709c0b61f16d4de5e9b4e9283ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c77b3fa6a8322cf117d9b991ffe12cdd9d45f303c054773a29ed0203255cc145832d36e0791c7675bcfdfc963ac18b93d853f8c1f0ac9b411ab1cac201ee8243
|
7
|
+
data.tar.gz: 3d769d50b61b9024d6e31ccd7f4f441a87e940e88b62def4533bf4f716cdd758d724cd6c82124cfd474e832d1a203d758eb01fdf790b922c16f55305a4d5b70a
|
data/lib/urabbit/publisher.rb
CHANGED
@@ -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(
|
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
|
data/lib/urabbit/rpc/client.rb
CHANGED
@@ -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
|
68
|
+
raise ServerError.new(@error['message'])
|
67
69
|
else
|
68
70
|
@result
|
69
71
|
end
|
data/lib/urabbit/rpc/server.rb
CHANGED
@@ -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
|
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
|
|
data/lib/urabbit/version.rb
CHANGED