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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddae04ef1c28f7eb451ee8988da5949ab0c97d6e
4
- data.tar.gz: 12490c056d64088711f79d9ddc2d8c227015efc0
3
+ metadata.gz: 572b27112d6f49732b12fb01d025b7786833b320
4
+ data.tar.gz: 69a1907ae06670f7f3f214e913ac90667d259e68
5
5
  SHA512:
6
- metadata.gz: 984436fe6ac5ce0783c6a8fabd2039c1d119dcc7c62cb749493818c44c3f6c6c2c6e350efd0555933012b74637e61b140d3dfbf8cf5c7981d2912248eb580e62
7
- data.tar.gz: 1fc475e7d83893f7129e4fd6b42736d647cac8b74cd03e93fc1167a331398d44c07ed3964e139e708ff66a19a22e89b17271c066c025b937a3eff07ce1bdd747
6
+ metadata.gz: 10cb2bd0d31d479d2169a07d71be51467ecd8e197e2a1d18cf3a4757c8fc7a4e40607335f1cbda668af85c6469bfdc10472502fb06a1efb4b0769217b0b9f0ff
7
+ data.tar.gz: ed6f1cf62d4ae65435f2fa88f338e9e5107e18d0c4b3d5b16f7aaaec4d31d501cf79c309d6a12943bd2ce6ee58923b6c9231d4f5351331f7f22a8c89a0833c50
@@ -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
@@ -37,6 +37,10 @@ module Msgr
37
37
  @connection ||= ::Bunny.new(config).tap { |b| b.start }
38
38
  end
39
39
 
40
+ def connect
41
+ connection
42
+ end
43
+
40
44
  def channel
41
45
  @channel ||= connection.create_channel
42
46
  end
@@ -12,7 +12,7 @@ module Msgr
12
12
  attr_reader :pool
13
13
 
14
14
  def initialize(config)
15
- log(:info) { "Initialize new dispatcher (#{Rails.env})..." }
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
@@ -27,6 +27,7 @@ module Msgr
27
27
  return unless cfg # no config given -> does not load Msgr
28
28
 
29
29
  Msgr.config = cfg
30
+ Msgr.client.connect
30
31
  end
31
32
 
32
33
  def parse_config(cfg)
@@ -1,7 +1,7 @@
1
1
  module Msgr
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 5
4
+ MINOR = 6
5
5
  PATCH = 0
6
6
  STAGE = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen