connection_pool 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes.md +5 -0
- data/connection_pool.gemspec +2 -0
- data/lib/connection_pool/version.rb +1 -1
- data/lib/connection_pool.rb +7 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea0776fcb09a3cc48ef4ca03774399e20b09e51039d0c47c1e4cb3bac621c52b
|
4
|
+
data.tar.gz: b955d6b4e984259f20ae8cf6414f59692f9a51848424231363643e0c16dd2a3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf57d8b5547502d91f5550ca6ea0be16905604c90e61efb6741e5ec3ce607c7a65f0b31e1673c96c60a06a2f64f5239cab6e94d3a50095fb822ea9b1c1bb2f0a
|
7
|
+
data.tar.gz: 4b42aa5aa67b0e45bbbc8a9f29ca3a969efd8ade3b6dfca6cff082f526ec65a2a2e5c8fa17f512d33470b82535af8b675fc80903ccd75db26748e9845dd9a612
|
data/Changes.md
CHANGED
data/connection_pool.gemspec
CHANGED
@@ -19,4 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_development_dependency "minitest", ">= 5.0.0"
|
20
20
|
s.add_development_dependency "rake"
|
21
21
|
s.required_ruby_version = ">= 2.5.0"
|
22
|
+
|
23
|
+
s.metadata = {"changelog_uri" => "https://github.com/mperham/connection_pool/blob/main/Changes.md", "rubygems_mfa_required" => "true"}
|
22
24
|
end
|
data/lib/connection_pool.rb
CHANGED
@@ -36,9 +36,10 @@ end
|
|
36
36
|
# Accepts the following options:
|
37
37
|
# - :size - number of connections to pool, defaults to 5
|
38
38
|
# - :timeout - amount of time to wait for a connection if none currently available, defaults to 5 seconds
|
39
|
+
# - :auto_reload_after_fork - automatically drop all connections after fork, defaults to true
|
39
40
|
#
|
40
41
|
class ConnectionPool
|
41
|
-
DEFAULTS = {size: 5, timeout: 5}
|
42
|
+
DEFAULTS = {size: 5, timeout: 5, auto_reload_after_fork: true}
|
42
43
|
|
43
44
|
def self.wrap(options, &block)
|
44
45
|
Wrapper.new(options, &block)
|
@@ -50,11 +51,12 @@ class ConnectionPool
|
|
50
51
|
|
51
52
|
def self.after_fork
|
52
53
|
INSTANCES.values.each do |pool|
|
54
|
+
next unless pool.auto_reload_after_fork
|
55
|
+
|
53
56
|
# We're on after fork, so we know all other threads are dead.
|
54
57
|
# All we need to do is to ensure the main thread doesn't have a
|
55
58
|
# checked out connection
|
56
59
|
pool.checkin(force: true)
|
57
|
-
|
58
60
|
pool.reload do |connection|
|
59
61
|
# Unfortunately we don't know what method to call to close the connection,
|
60
62
|
# so we try the most common one.
|
@@ -92,6 +94,7 @@ class ConnectionPool
|
|
92
94
|
|
93
95
|
@size = Integer(options.fetch(:size))
|
94
96
|
@timeout = options.fetch(:timeout)
|
97
|
+
@auto_reload_after_fork = options.fetch(:auto_reload_after_fork)
|
95
98
|
|
96
99
|
@available = TimedStack.new(@size, &block)
|
97
100
|
@key = :"pool-#{@available.object_id}"
|
@@ -159,6 +162,8 @@ class ConnectionPool
|
|
159
162
|
|
160
163
|
# Size of this connection pool
|
161
164
|
attr_reader :size
|
165
|
+
# Automatically drop all connections after fork
|
166
|
+
attr_reader :auto_reload_after_fork
|
162
167
|
|
163
168
|
# Number of pool entries available for checkout at this instant.
|
164
169
|
def available
|
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: 2.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Perham
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-05-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -72,7 +72,9 @@ files:
|
|
72
72
|
homepage: https://github.com/mperham/connection_pool
|
73
73
|
licenses:
|
74
74
|
- MIT
|
75
|
-
metadata:
|
75
|
+
metadata:
|
76
|
+
changelog_uri: https://github.com/mperham/connection_pool/blob/main/Changes.md
|
77
|
+
rubygems_mfa_required: 'true'
|
76
78
|
post_install_message:
|
77
79
|
rdoc_options: []
|
78
80
|
require_paths:
|