pgb_connection_reaper_rb 0.1.3 → 0.2.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 +4 -4
- data/.github/workflows/ci.yml +34 -0
- data/.github/workflows/release.yml +44 -0
- data/.gitignore +3 -0
- data/.tool-versions +1 -0
- data/Appraisals +22 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +67 -28
- data/README.md +30 -0
- data/Rakefile +6 -0
- data/lib/pgb_connection_reaper_rb/postgresql_adapter_extension.rb +12 -12
- data/lib/pgb_connection_reaper_rb/reaper.rb +4 -4
- data/lib/pgb_connection_reaper_rb/version.rb +1 -1
- data/pgb_connection_reaper_rb.gemspec +4 -3
- metadata +26 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df4188fc6c40fca8a527004d05f2af6e9643e8cea1ab87e609ff8e8b30e95faa
|
|
4
|
+
data.tar.gz: 468bd15baffee28aa71d5881733892877388922151ae4e40863e5d8116cea451
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: abf64c4573c1b21563b0913bbb67f8c994e5f7d34f29481f77184662224bae66f79404071cd61563c34359afde35738071b5c0879613fadcbd9d8b2cc877213a
|
|
7
|
+
data.tar.gz: 75d765f2cf9d9436ada42ee4f29b4f10a8aacc1b30f9640330dbbf9e3f0e08a07c5b407329b087411a25e95e81c89f2398705db41daafe48c41f40f8ce752202
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
ruby: ['3.1', '3.2', '3.3']
|
|
17
|
+
|
|
18
|
+
name: Ruby ${{ matrix.ruby }}
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Set up Ruby
|
|
24
|
+
uses: ruby/setup-ruby@v1
|
|
25
|
+
with:
|
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
|
27
|
+
bundler: '2.5.11'
|
|
28
|
+
bundler-cache: true
|
|
29
|
+
|
|
30
|
+
- name: Install Appraisal dependencies
|
|
31
|
+
run: bundle exec appraisal install
|
|
32
|
+
|
|
33
|
+
- name: Run tests against all ActiveRecord versions
|
|
34
|
+
run: bundle exec appraisal rspec
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
test:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
|
|
13
|
+
- name: Set up Ruby
|
|
14
|
+
uses: ruby/setup-ruby@v1
|
|
15
|
+
with:
|
|
16
|
+
ruby-version: 3.3
|
|
17
|
+
bundler: '2.5.11'
|
|
18
|
+
bundler-cache: true
|
|
19
|
+
|
|
20
|
+
- name: Install Appraisal dependencies
|
|
21
|
+
run: bundle exec appraisal install
|
|
22
|
+
|
|
23
|
+
- name: Run tests
|
|
24
|
+
run: bundle exec appraisal rspec
|
|
25
|
+
|
|
26
|
+
release:
|
|
27
|
+
needs: test
|
|
28
|
+
permissions:
|
|
29
|
+
contents: write
|
|
30
|
+
id-token: write
|
|
31
|
+
|
|
32
|
+
name: Release
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
|
|
38
|
+
- uses: ruby/setup-ruby@v1
|
|
39
|
+
with:
|
|
40
|
+
ruby-version: 3.3
|
|
41
|
+
bundler: '2.5.11'
|
|
42
|
+
bundler-cache: true
|
|
43
|
+
|
|
44
|
+
- uses: rubygems/release-gem@v1
|
data/.gitignore
CHANGED
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby 3.4.1
|
data/Appraisals
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Test against different ActiveRecord versions
|
|
4
|
+
appraise "activerecord-6.1" do
|
|
5
|
+
gem "activerecord", "~> 6.1.0"
|
|
6
|
+
gem "activesupport", "~> 6.1.0"
|
|
7
|
+
# Fix for Ruby 3.4+ compatibility with ActiveRecord 6.1
|
|
8
|
+
gem "logger", "< 1.6.0"
|
|
9
|
+
gem "base64"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
appraise "activerecord-7.0" do
|
|
13
|
+
gem "activerecord", "~> 7.0.0"
|
|
14
|
+
gem "activesupport", "~> 7.0.0"
|
|
15
|
+
# Fix for Ruby 3.4+ compatibility with ActiveRecord 7.0
|
|
16
|
+
gem "logger", "< 1.6.0"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
appraise "activerecord-7.1" do
|
|
20
|
+
gem "activerecord", "~> 7.1.0"
|
|
21
|
+
gem "activesupport", "~> 7.1.0"
|
|
22
|
+
end
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,52 +1,91 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
pgb_connection_reaper_rb (0.
|
|
5
|
-
activerecord (>=
|
|
6
|
-
activesupport (>=
|
|
4
|
+
pgb_connection_reaper_rb (0.2.2)
|
|
5
|
+
activerecord (>= 6.1)
|
|
6
|
+
activesupport (>= 6.1)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
activemodel (7.
|
|
12
|
-
activesupport (= 7.
|
|
13
|
-
activerecord (7.
|
|
14
|
-
activemodel (= 7.
|
|
15
|
-
activesupport (= 7.
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
activemodel (7.2.2.2)
|
|
12
|
+
activesupport (= 7.2.2.2)
|
|
13
|
+
activerecord (7.2.2.2)
|
|
14
|
+
activemodel (= 7.2.2.2)
|
|
15
|
+
activesupport (= 7.2.2.2)
|
|
16
|
+
timeout (>= 0.4.0)
|
|
17
|
+
activesupport (7.2.2.2)
|
|
18
|
+
base64
|
|
19
|
+
benchmark (>= 0.3)
|
|
20
|
+
bigdecimal
|
|
21
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
22
|
+
connection_pool (>= 2.2.5)
|
|
23
|
+
drb
|
|
18
24
|
i18n (>= 1.6, < 2)
|
|
25
|
+
logger (>= 1.4.2)
|
|
19
26
|
minitest (>= 5.1)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
securerandom (>= 0.3)
|
|
28
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
29
|
+
appraisal (2.5.0)
|
|
30
|
+
bundler
|
|
31
|
+
rake
|
|
32
|
+
thor (>= 0.14.0)
|
|
33
|
+
base64 (0.3.0)
|
|
34
|
+
benchmark (0.4.1)
|
|
35
|
+
bigdecimal (3.3.1)
|
|
36
|
+
concurrent-ruby (1.3.5)
|
|
37
|
+
connection_pool (2.5.4)
|
|
38
|
+
diff-lcs (1.6.2)
|
|
39
|
+
drb (2.2.3)
|
|
40
|
+
i18n (1.14.7)
|
|
24
41
|
concurrent-ruby (~> 1.0)
|
|
25
|
-
|
|
42
|
+
logger (1.7.0)
|
|
43
|
+
minitest (5.26.0)
|
|
44
|
+
mutex_m (0.3.0)
|
|
26
45
|
rake (12.3.3)
|
|
27
|
-
rspec (3.
|
|
28
|
-
rspec-core (~> 3.
|
|
29
|
-
rspec-expectations (~> 3.
|
|
30
|
-
rspec-mocks (~> 3.
|
|
31
|
-
rspec-core (3.
|
|
32
|
-
rspec-support (~> 3.
|
|
33
|
-
rspec-expectations (3.
|
|
46
|
+
rspec (3.13.1)
|
|
47
|
+
rspec-core (~> 3.13.0)
|
|
48
|
+
rspec-expectations (~> 3.13.0)
|
|
49
|
+
rspec-mocks (~> 3.13.0)
|
|
50
|
+
rspec-core (3.13.5)
|
|
51
|
+
rspec-support (~> 3.13.0)
|
|
52
|
+
rspec-expectations (3.13.5)
|
|
34
53
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
35
|
-
rspec-support (~> 3.
|
|
36
|
-
rspec-mocks (3.
|
|
54
|
+
rspec-support (~> 3.13.0)
|
|
55
|
+
rspec-mocks (3.13.5)
|
|
37
56
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
38
|
-
rspec-support (~> 3.
|
|
39
|
-
rspec-support (3.
|
|
57
|
+
rspec-support (~> 3.13.0)
|
|
58
|
+
rspec-support (3.13.6)
|
|
59
|
+
securerandom (0.4.1)
|
|
60
|
+
sqlite3 (1.7.3-aarch64-linux)
|
|
61
|
+
sqlite3 (1.7.3-arm-linux)
|
|
62
|
+
sqlite3 (1.7.3-arm64-darwin)
|
|
63
|
+
sqlite3 (1.7.3-x86-linux)
|
|
64
|
+
sqlite3 (1.7.3-x86_64-darwin)
|
|
65
|
+
sqlite3 (1.7.3-x86_64-linux)
|
|
66
|
+
thor (1.4.0)
|
|
67
|
+
timeout (0.4.3)
|
|
40
68
|
tzinfo (2.0.6)
|
|
41
69
|
concurrent-ruby (~> 1.0)
|
|
42
70
|
|
|
43
71
|
PLATFORMS
|
|
44
|
-
|
|
72
|
+
aarch64-linux
|
|
73
|
+
arm-linux
|
|
74
|
+
arm64-darwin
|
|
75
|
+
x86-linux
|
|
76
|
+
x86_64-darwin
|
|
77
|
+
x86_64-linux
|
|
45
78
|
|
|
46
79
|
DEPENDENCIES
|
|
80
|
+
appraisal (~> 2.4)
|
|
81
|
+
benchmark
|
|
82
|
+
bigdecimal
|
|
83
|
+
logger
|
|
84
|
+
mutex_m
|
|
47
85
|
pgb_connection_reaper_rb!
|
|
48
86
|
rake (~> 12.0)
|
|
49
87
|
rspec (~> 3.0)
|
|
88
|
+
sqlite3 (~> 1.4)
|
|
50
89
|
|
|
51
90
|
BUNDLED WITH
|
|
52
|
-
2.
|
|
91
|
+
2.5.11
|
data/README.md
CHANGED
|
@@ -35,10 +35,40 @@ Or install it yourself as:
|
|
|
35
35
|
idle_timeout: 300
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
## Compatibility
|
|
39
|
+
|
|
40
|
+
This gem supports:
|
|
41
|
+
- **Ruby**: 3.1+
|
|
42
|
+
- **ActiveRecord**: 6.1+, 7.0+, 7.1+, 7.2+
|
|
43
|
+
- **Rails**: 6.1+, 7.0+, 7.1+, 7.2+
|
|
44
|
+
|
|
38
45
|
## Development
|
|
39
46
|
|
|
40
47
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
41
48
|
|
|
49
|
+
### Testing Multiple ActiveRecord Versions
|
|
50
|
+
|
|
51
|
+
This project uses [Appraisal](https://github.com/thoughtbot/appraisal) to test against multiple ActiveRecord versions:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Install appraisal gemfiles
|
|
55
|
+
bundle exec appraisal install
|
|
56
|
+
|
|
57
|
+
# Run tests against all ActiveRecord versions
|
|
58
|
+
bundle exec appraisal rspec
|
|
59
|
+
|
|
60
|
+
# Run tests against a specific ActiveRecord version
|
|
61
|
+
bundle exec appraisal activerecord-7.1 rspec
|
|
62
|
+
bundle exec appraisal activerecord-7.0 rspec
|
|
63
|
+
bundle exec appraisal activerecord-6.1 rspec
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Available appraisal configurations:
|
|
67
|
+
- `activerecord-6.1` - ActiveRecord 6.1.x
|
|
68
|
+
- `activerecord-7.0` - ActiveRecord 7.0.x
|
|
69
|
+
- `activerecord-7.1` - ActiveRecord 7.1.x
|
|
70
|
+
- `activerecord-7.2` - ActiveRecord 7.2.x
|
|
71
|
+
|
|
42
72
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
43
73
|
|
|
44
74
|
## Contributing
|
data/Rakefile
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
module PgbConnectionReaperRb
|
|
4
4
|
module PostgreSQLAdapterExtension
|
|
5
|
-
def reconnect!
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@lock
|
|
9
|
-
else
|
|
10
|
-
# Rails 4.2
|
|
11
|
-
ActiveRecord::Base.connection_pool.instance_variable_get(:@mon_data)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
lock.synchronize do
|
|
5
|
+
def reconnect!(**args)
|
|
6
|
+
# Rails 7.1+ handles locking and disconnect/connect cycle internally
|
|
7
|
+
if ActiveRecord.version >= Gem::Version.new("7.1.0")
|
|
15
8
|
super
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
else
|
|
10
|
+
# Rails 6.x and earlier: ensure thread-safe reconnection with manual lock
|
|
11
|
+
lock = defined?(@lock) ? @lock : ActiveRecord::Base.connection_pool.instance_variable_get(:@mon_data)
|
|
12
|
+
|
|
13
|
+
lock.synchronize do
|
|
14
|
+
super
|
|
15
|
+
disconnect!
|
|
16
|
+
connect
|
|
17
|
+
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
end
|
|
@@ -14,13 +14,13 @@ module PgbConnectionReaperRb
|
|
|
14
14
|
|
|
15
15
|
attr_reader :connected_at, :pgb_ttl
|
|
16
16
|
|
|
17
|
-
def reconnect!(
|
|
18
|
-
super
|
|
17
|
+
def reconnect!(**args)
|
|
18
|
+
super
|
|
19
19
|
@connected_at = Concurrent.monotonic_time
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def verify!(
|
|
23
|
-
super
|
|
22
|
+
def verify!()
|
|
23
|
+
super
|
|
24
24
|
reconnect! if eligible?
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
spec.summary = 'Gem for forcing cycling disconnections for Rails connections to PGBouncer'
|
|
12
12
|
spec.homepage = 'https://github.com/surgeventures/pgb_connection_reaper_rb'
|
|
13
13
|
spec.license = 'MIT'
|
|
14
|
-
spec.required_ruby_version = '>=
|
|
14
|
+
spec.required_ruby_version = '>= 3.1.0'
|
|
15
15
|
|
|
16
16
|
spec.metadata['homepage_uri'] = spec.homepage
|
|
17
17
|
spec.metadata['source_code_uri'] = 'https://github.com/surgeventures/pgb_connection_reaper_rb'
|
|
@@ -26,7 +26,8 @@ Gem::Specification.new do |spec|
|
|
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
27
27
|
spec.require_paths = ['lib']
|
|
28
28
|
|
|
29
|
-
spec.add_dependency 'activerecord', '>=
|
|
30
|
-
spec.add_dependency 'activesupport', '>=
|
|
29
|
+
spec.add_dependency 'activerecord', '>= 6.1'
|
|
30
|
+
spec.add_dependency 'activesupport', '>= 6.1'
|
|
31
31
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
32
|
+
spec.add_development_dependency 'appraisal', '~> 2.4'
|
|
32
33
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pgb_connection_reaper_rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anton Borisov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-10-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -16,28 +16,28 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '6.1'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '6.1'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: activesupport
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '6.1'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '6.1'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rspec
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,6 +52,20 @@ dependencies:
|
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: appraisal
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '2.4'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '2.4'
|
|
55
69
|
description:
|
|
56
70
|
email:
|
|
57
71
|
- anton.borisov@fresha.com
|
|
@@ -59,10 +73,14 @@ executables: []
|
|
|
59
73
|
extensions: []
|
|
60
74
|
extra_rdoc_files: []
|
|
61
75
|
files:
|
|
76
|
+
- ".github/workflows/ci.yml"
|
|
77
|
+
- ".github/workflows/release.yml"
|
|
62
78
|
- ".gitignore"
|
|
63
79
|
- ".rspec"
|
|
64
80
|
- ".rubocop.yml"
|
|
81
|
+
- ".tool-versions"
|
|
65
82
|
- ".travis.yml"
|
|
83
|
+
- Appraisals
|
|
66
84
|
- CODE_OF_CONDUCT.md
|
|
67
85
|
- Gemfile
|
|
68
86
|
- Gemfile.lock
|
|
@@ -93,14 +111,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
93
111
|
requirements:
|
|
94
112
|
- - ">="
|
|
95
113
|
- !ruby/object:Gem::Version
|
|
96
|
-
version:
|
|
114
|
+
version: 3.1.0
|
|
97
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
116
|
requirements:
|
|
99
117
|
- - ">="
|
|
100
118
|
- !ruby/object:Gem::Version
|
|
101
119
|
version: '0'
|
|
102
120
|
requirements: []
|
|
103
|
-
rubygems_version: 3.
|
|
121
|
+
rubygems_version: 3.5.22
|
|
104
122
|
signing_key:
|
|
105
123
|
specification_version: 4
|
|
106
124
|
summary: Gem for forcing cycling disconnections for Rails connections to PGBouncer
|