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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fdb17a5ea51eb80dc3d0aa206a2693ca9ef5f90ed0d37d2c2ce1a4a560e195a5
4
- data.tar.gz: 7151fd012b7edd7f3d4b9fce6e1ffc30840da40bcb52ac94a47a7f174e70340c
3
+ metadata.gz: df4188fc6c40fca8a527004d05f2af6e9643e8cea1ab87e609ff8e8b30e95faa
4
+ data.tar.gz: 468bd15baffee28aa71d5881733892877388922151ae4e40863e5d8116cea451
5
5
  SHA512:
6
- metadata.gz: e931b1ff99f27a8894585496abcffda720d672f2245d52f7e46ad9f872d05f59047f6814fd584c63edb1a4fbc1a8856068c970be8b7b36b0239a8c1ce702283f
7
- data.tar.gz: 6ecf1855b0c6e10a5a0bc7e0bb86d8e3931b7eabfda52f53dbf732f9c946ec355c3c76ff3a39bbda2cee23229da6d12516dc951be507b4f4388a9a09594ccdb1
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
@@ -9,3 +9,6 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ # appraisal generated gemfiles
14
+ /gemfiles/
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
@@ -7,3 +7,10 @@ gemspec
7
7
 
8
8
  gem 'rake', '~> 12.0'
9
9
  gem 'rspec', '~> 3.0'
10
+ gem 'sqlite3', '~> 1.4'
11
+
12
+ # Required for Ruby 3.4+ compatibility with ActiveSupport 7.0.x
13
+ gem 'mutex_m'
14
+ gem 'logger'
15
+ gem 'bigdecimal'
16
+ gem 'benchmark'
data/Gemfile.lock CHANGED
@@ -1,52 +1,91 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pgb_connection_reaper_rb (0.1.1)
5
- activerecord (>= 4.2)
6
- activesupport (>= 4.2)
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.0.8.4)
12
- activesupport (= 7.0.8.4)
13
- activerecord (7.0.8.4)
14
- activemodel (= 7.0.8.4)
15
- activesupport (= 7.0.8.4)
16
- activesupport (7.0.8.4)
17
- concurrent-ruby (~> 1.0, >= 1.0.2)
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
- tzinfo (~> 2.0)
21
- concurrent-ruby (1.3.4)
22
- diff-lcs (1.5.0)
23
- i18n (1.14.6)
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
- minitest (5.25.1)
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.12.0)
28
- rspec-core (~> 3.12.0)
29
- rspec-expectations (~> 3.12.0)
30
- rspec-mocks (~> 3.12.0)
31
- rspec-core (3.12.1)
32
- rspec-support (~> 3.12.0)
33
- rspec-expectations (3.12.2)
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.12.0)
36
- rspec-mocks (3.12.5)
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.12.0)
39
- rspec-support (3.12.0)
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
- ruby
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.1.4
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
@@ -5,4 +5,10 @@ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
+ begin
9
+ require 'appraisal/task'
10
+ rescue LoadError
11
+ # appraisal not available
12
+ end
13
+
8
14
  task default: :spec
@@ -2,19 +2,19 @@
2
2
 
3
3
  module PgbConnectionReaperRb
4
4
  module PostgreSQLAdapterExtension
5
- def reconnect!
6
- lock = if defined?(@lock)
7
- # Rails 6+
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
- disconnect!
17
- connect
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!(*args)
18
- super(*args)
17
+ def reconnect!(**args)
18
+ super
19
19
  @connected_at = Concurrent.monotonic_time
20
20
  end
21
21
 
22
- def verify!(*args)
23
- super(*args)
22
+ def verify!()
23
+ super
24
24
  reconnect! if eligible?
25
25
  end
26
26
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgbConnectionReaperRb
4
- VERSION = '0.1.3'
4
+ VERSION = '0.2.2'
5
5
  end
@@ -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 = '>= 2.5.0'
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', '>= 4.2'
30
- spec.add_dependency 'activesupport', '>= 4.2'
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.1.3
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: 2024-11-25 00:00:00.000000000 Z
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: '4.2'
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: '4.2'
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: '4.2'
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: '4.2'
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: 2.5.0
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.1.6
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