connection_pool 2.4.0 → 2.4.1

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: e87682a6e57e8b0214de9c0713a7466a2b06399dc52d700fbf182cdf9e5b6606
4
- data.tar.gz: d12337513b62d4677663403c512afad165275bdf848987182ce03637a1de6482
3
+ metadata.gz: ea0776fcb09a3cc48ef4ca03774399e20b09e51039d0c47c1e4cb3bac621c52b
4
+ data.tar.gz: b955d6b4e984259f20ae8cf6414f59692f9a51848424231363643e0c16dd2a3f
5
5
  SHA512:
6
- metadata.gz: eca2c1f8ebe52039f00df70ddfe5525cc0408acd8ae9849a8d1412bec670e7d3a05d3609db933e3e906cd83307d39f754dd5f1d7b48b50b847090b5bf485b55a
7
- data.tar.gz: fc9a62b4b0ba5a406543e8f6399bd566f2f31c6c9a6ce2772e3550c1c2a75945c8a34defeda10c83e23cbfe5fe50d0e8861f57ea23935d7c97540aa97b04a635
6
+ metadata.gz: bf57d8b5547502d91f5550ca6ea0be16905604c90e61efb6741e5ec3ce607c7a65f0b31e1673c96c60a06a2f64f5239cab6e94d3a50095fb822ea9b1c1bb2f0a
7
+ data.tar.gz: 4b42aa5aa67b0e45bbbc8a9f29ca3a969efd8ade3b6dfca6cff082f526ec65a2a2e5c8fa17f512d33470b82535af8b675fc80903ccd75db26748e9845dd9a612
data/Changes.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # connection_pool Changelog
2
2
 
3
+ 2.4.1
4
+ ------
5
+
6
+ - New `auto_reload_after_fork` config option to disable auto-drop [#177, shayonj]
7
+
3
8
  2.4.0
4
9
  ------
5
10
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  class ConnectionPool
2
- VERSION = "2.4.0"
2
+ VERSION = "2.4.1"
3
3
  end
@@ -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.0
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-03-24 00:00:00.000000000 Z
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: