connection_pool 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60f53f4a83f6a13be41059753aeff5fad1518a45946aa13ab29111f1612c5119
4
- data.tar.gz: 7edefa375ea7f3852eee9d7644f2aae955119e0cd96049697b7f38bfc54e5c87
3
+ metadata.gz: a064d41333b8b92fcb23617701011f1b34e6348b324048ca16e5cb758d31f05f
4
+ data.tar.gz: 7ca1cc56ff7d020f2b7f2cee01b2008502faadf563dad010c2b8eee4a0b83dcd
5
5
  SHA512:
6
- metadata.gz: 3007eb8a2cf804da6b3850162098b221a5a613244ba20506fed109e3a47e0046099ba56c48ccd8a260a3afc13362552ddd9040a512ca1b512cfae1f18937c32b
7
- data.tar.gz: 4cdb681918cefe624b3c00e6d7580330f120c6c53cc414e694d6568eee7f24ed109d69ec150c7a7ccbf5dec17ffb1cfdc8422e78bcb9d1b436240bb81c5464a6
6
+ metadata.gz: 1c7554d540f6aefcd356154246a1cdcab5e4ddea745e9a580261fba0635e6b711a9e0781691503f20aca7faaf982e2ba8f5f48cc71ff2a4f67053039e947ba3d
7
+ data.tar.gz: 431dcf74c39f6a9db1503290a227f5780c4b03e392ef25709245e63d0ca46a2f0f6cc0792a5241e615eafd92663aa38c1165aae99f6dffb0783f5b442846582f
data/Changes.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # connection_pool Changelog
2
2
 
3
+ 3.0.2
4
+ ------
5
+
6
+ - Support :name keyword for backwards compatibility [#210]
7
+
8
+ 3.0.1
9
+ ------
10
+
11
+ - Add missing `fork.rb` to gemspec.
12
+
3
13
  3.0.0
4
14
  ------
5
15
 
@@ -10,8 +10,11 @@ Gem::Specification.new do |s|
10
10
  s.description = s.summary = "Generic connection pool for Ruby"
11
11
 
12
12
  s.files = ["Changes.md", "LICENSE", "README.md", "connection_pool.gemspec",
13
- "lib/connection_pool.rb", "lib/connection_pool/timed_stack.rb",
14
- "lib/connection_pool/version.rb", "lib/connection_pool/wrapper.rb"]
13
+ "lib/connection_pool.rb",
14
+ "lib/connection_pool/timed_stack.rb",
15
+ "lib/connection_pool/version.rb",
16
+ "lib/connection_pool/fork.rb",
17
+ "lib/connection_pool/wrapper.rb"]
15
18
  s.executables = []
16
19
  s.require_paths = ["lib"]
17
20
  s.license = "MIT"
@@ -0,0 +1,40 @@
1
+ class ConnectionPool
2
+ if Process.respond_to?(:fork)
3
+ INSTANCES = ObjectSpace::WeakMap.new
4
+ private_constant :INSTANCES
5
+
6
+ def self.after_fork
7
+ INSTANCES.each_value do |pool|
8
+ # We're in after_fork, so we know all other threads are dead.
9
+ # All we need to do is ensure the main thread doesn't have a
10
+ # checked out connection
11
+ pool.checkin(force: true)
12
+ pool.reload do |connection|
13
+ # Unfortunately we don't know what method to call to close the connection,
14
+ # so we try the most common one.
15
+ connection.close if connection.respond_to?(:close)
16
+ end
17
+ end
18
+ nil
19
+ end
20
+
21
+ module ForkTracker
22
+ def _fork
23
+ pid = super
24
+ if pid == 0
25
+ ConnectionPool.after_fork
26
+ end
27
+ pid
28
+ end
29
+ end
30
+ Process.singleton_class.prepend(ForkTracker)
31
+ else
32
+ # JRuby, et al
33
+ INSTANCES = nil
34
+ private_constant :INSTANCES
35
+
36
+ def self.after_fork
37
+ # noop
38
+ end
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  class ConnectionPool
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.2"
3
3
  end
@@ -45,7 +45,7 @@ class ConnectionPool
45
45
 
46
46
  attr_reader :size
47
47
 
48
- def initialize(timeout: 5, size: 5, auto_reload_after_fork: true, &)
48
+ def initialize(timeout: 5, size: 5, auto_reload_after_fork: true, name: nil, &)
49
49
  raise ArgumentError, "Connection pool requires a block" unless block_given?
50
50
 
51
51
  @size = Integer(size)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: connection_pool
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
@@ -65,6 +65,7 @@ files:
65
65
  - README.md
66
66
  - connection_pool.gemspec
67
67
  - lib/connection_pool.rb
68
+ - lib/connection_pool/fork.rb
68
69
  - lib/connection_pool/timed_stack.rb
69
70
  - lib/connection_pool/version.rb
70
71
  - lib/connection_pool/wrapper.rb