urabbit 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/urabbit/version.rb +1 -1
- data/lib/urabbit.rb +16 -7
- 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: d5a7ba1bc144820029a5de3c13bc0d162ac284e3
|
4
|
+
data.tar.gz: 7a8e01501892c9a51c9a2e806fc3206a6bc294e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f1c932ea346f3d413478a9758bd9a7b8e1a4228be989f4ff79763b15c00c05c087c6550e01dd01c87a4ed5928629c4575b3d31dac66ea55107b208ee66bbcf4
|
7
|
+
data.tar.gz: daa3dbf4de77cdf921ef189c4bc4f762f2d1832d833eedbbfc6bd806703cb241817e5366d5d26047f3aa8f0f86b4316702b003b211535a7d2434e58c5676666f
|
data/lib/urabbit/version.rb
CHANGED
data/lib/urabbit.rb
CHANGED
@@ -5,6 +5,7 @@ require "securerandom"
|
|
5
5
|
|
6
6
|
module Urabbit
|
7
7
|
class Error < Exception; end
|
8
|
+
@mutex = Mutex.new
|
8
9
|
|
9
10
|
def self.logger
|
10
11
|
@logger ||= if defined?(Rails)
|
@@ -19,16 +20,24 @@ module Urabbit
|
|
19
20
|
end
|
20
21
|
|
21
22
|
# A single connection shared between threads.
|
22
|
-
def self.
|
23
|
-
@
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
def self.connection(cloudamqp_url = ENV["CLOUDAMQP_URL"])
|
24
|
+
@mutex.synchronize do
|
25
|
+
@connection ||= begin
|
26
|
+
connection = Bunny.new(cloudamqp_url, logger: logger)
|
27
|
+
connection.start
|
28
|
+
connection
|
29
|
+
rescue Bunny::Exception
|
30
|
+
raise Error.new("Error connecting to RabbitMQ")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.disconnect
|
36
|
+
@connection = nil
|
28
37
|
end
|
29
38
|
|
30
39
|
def self.create_channel
|
31
|
-
|
40
|
+
connection.create_channel
|
32
41
|
end
|
33
42
|
end
|
34
43
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: urabbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacek Becela
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|