msgr 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/msgr/client.rb +11 -2
- data/lib/msgr/connection.rb +4 -0
- data/lib/msgr/dispatcher.rb +6 -1
- data/lib/msgr/railtie.rb +1 -0
- data/lib/msgr/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: 572b27112d6f49732b12fb01d025b7786833b320
|
4
|
+
data.tar.gz: 69a1907ae06670f7f3f214e913ac90667d259e68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10cb2bd0d31d479d2169a07d71be51467ecd8e197e2a1d18cf3a4757c8fc7a4e40607335f1cbda668af85c6469bfdc10472502fb06a1efb4b0769217b0b9f0ff
|
7
|
+
data.tar.gz: ed6f1cf62d4ae65435f2fa88f338e9e5107e18d0c4b3d5b16f7aaaec4d31d501cf79c309d6a12943bd2ce6ee58923b6c9231d4f5351331f7f22a8c89a0833c50
|
data/lib/msgr/client.rb
CHANGED
@@ -45,14 +45,23 @@ module Msgr
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def connect
|
49
|
+
mutex.synchronize do
|
50
|
+
check_process!
|
51
|
+
return if connection.running?
|
52
|
+
|
53
|
+
log(:info) { "Connect to #{uri}..." }
|
54
|
+
|
55
|
+
connection.connect
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
48
59
|
def stop
|
49
60
|
mutex.synchronize do
|
50
61
|
check_process!
|
51
62
|
|
52
63
|
log(:info) { "Stop on #{uri}..." }
|
53
64
|
|
54
|
-
return unless connection.running?
|
55
|
-
|
56
65
|
connection.release
|
57
66
|
connection.close
|
58
67
|
dispatcher.shutdown
|
data/lib/msgr/connection.rb
CHANGED
data/lib/msgr/dispatcher.rb
CHANGED
@@ -12,7 +12,7 @@ module Msgr
|
|
12
12
|
attr_reader :pool
|
13
13
|
|
14
14
|
def initialize(config)
|
15
|
-
log(:info) { "Initialize new dispatcher (#{
|
15
|
+
log(:info) { "Initialize new dispatcher (#{config[:max]} threads)..." }
|
16
16
|
|
17
17
|
@pool = ::Concurrent::CachedThreadPool.new(max: config[:max])
|
18
18
|
end
|
@@ -37,6 +37,11 @@ module Msgr
|
|
37
37
|
"Dispatcher error: #{error.class.name}: #{error}\n" +
|
38
38
|
error.backtrace.join("\n")
|
39
39
|
end
|
40
|
+
ensure
|
41
|
+
if defined?(ActiveRecord) && ActiveRecord::Base.active_connection?
|
42
|
+
log(:debug) { 'Release used AR connection for dispatcher thread.' }
|
43
|
+
ActiveRecord::Base.release_connection
|
44
|
+
end
|
40
45
|
end
|
41
46
|
|
42
47
|
def shutdown
|
data/lib/msgr/railtie.rb
CHANGED
data/lib/msgr/version.rb
CHANGED