multiple_man 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/multiple_man/connection.rb +6 -38
- data/lib/multiple_man/version.rb +1 -1
- 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: d859ac14aeccc95ff5ab2ec4d1b5e4cb07f18e77
|
4
|
+
data.tar.gz: e5723029260e45a9012c8394ca3b7c4e9fab8535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f696e8233f25addccab4bd17b2fe2757dd798664aaf727327ce615b60b92a18e3e2da568d10af11b26e780ffd1be0ead24b922a4a30bb1fda01def94ed636167
|
7
|
+
data.tar.gz: 750cd59c5e45f14aa97f915bd9ddb2a371ff7f982435cb0629fb3821204de619a132950bcbde2ed1721b1ecd2c1548930caa74e27cd7d98d613b8f4bb93f9fa5
|
@@ -1,18 +1,19 @@
|
|
1
1
|
require 'bunny'
|
2
|
+
require 'connection_pool'
|
2
3
|
require 'active_support/core_ext/module'
|
3
4
|
|
4
5
|
module MultipleMan
|
5
6
|
class Connection
|
6
|
-
@mutex = Mutex.new
|
7
7
|
|
8
8
|
def self.connect
|
9
|
+
connection = Bunny.new(MultipleMan.configuration.connection)
|
10
|
+
MultipleMan.logger.debug "Connecting to #{MultipleMan.configuration.connection}"
|
11
|
+
connection.start
|
9
12
|
channel = connection.create_channel
|
10
13
|
yield new(channel) if block_given?
|
11
|
-
rescue Bunny::Exception
|
12
|
-
reset!
|
13
|
-
retry
|
14
14
|
ensure
|
15
15
|
channel.close if channel && channel.open?
|
16
|
+
connection.close if connection && connection.open?
|
16
17
|
end
|
17
18
|
|
18
19
|
attr_reader :topic
|
@@ -22,24 +23,6 @@ module MultipleMan
|
|
22
23
|
self.topic = channel.topic(topic_name)
|
23
24
|
end
|
24
25
|
|
25
|
-
def self.connection
|
26
|
-
@mutex.synchronize do
|
27
|
-
@connection ||= begin
|
28
|
-
connection = Bunny.new(MultipleMan.configuration.connection, heartbeat: 5)
|
29
|
-
MultipleMan.logger.debug "Connecting to #{MultipleMan.configuration.connection}"
|
30
|
-
connection.start
|
31
|
-
|
32
|
-
connection
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.reset!
|
38
|
-
@connection.close if @connection
|
39
|
-
|
40
|
-
@connection = nil
|
41
|
-
end
|
42
|
-
|
43
26
|
def topic_name
|
44
27
|
MultipleMan.configuration.topic_name
|
45
28
|
end
|
@@ -50,21 +33,6 @@ module MultipleMan
|
|
50
33
|
|
51
34
|
attr_accessor :channel
|
52
35
|
attr_writer :topic
|
53
|
-
end
|
54
|
-
end
|
55
36
|
|
56
|
-
|
57
|
-
|
58
|
-
# Possible usage
|
59
|
-
|
60
|
-
Unicorn.after_fork do
|
61
|
-
MultipleMan::Connection.reset!
|
62
|
-
end
|
63
|
-
|
64
|
-
Sidekiq.configure_server do |config|
|
65
|
-
MultipleMan::Connection.reset!
|
66
|
-
end
|
67
|
-
|
68
|
-
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
69
|
-
MultipleMan::Connection.reset! if forked
|
37
|
+
end
|
70
38
|
end
|
data/lib/multiple_man/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multiple_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Brunner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|