pgb_connection_reaper_rb 0.1.1 → 0.2.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: 572afe18ef474649611a89d55319a6dfd2889c404b5f81be1a8e3319bd1be2a2
4
- data.tar.gz: 89f5fe8ef74bad4c3530a31adb380c9effaac7edbe31c2eeb35524945650b1bc
3
+ metadata.gz: 04357ed005c13e58c917f88aedbb0683ee95f0774568167af39b414e72883c0c
4
+ data.tar.gz: 58bf334081b392d3b8ae58b8ae44adecf4caa4281abf6ccfa1365c25059f126c
5
5
  SHA512:
6
- metadata.gz: 41ec26720b292406771b9efed8ed88ac9442042caa62f753c763e4079d5864e55f6b5099910255455b96853e9e78839205e1a461fad9f1d42249ef0e299d227a
7
- data.tar.gz: fe22aff3a0c69b48668b30c4bd667de385bd301e25a07cba073cdcc0efc5e6cbe8798f0f2971cbdb030830e7c58a644bc09f5849628c0823093b603da38f1f7e
6
+ metadata.gz: e00e07841d134493600258d17d97d201e8a92d0326a84957c0feba5289a807dd09dfc78edfad45d10ffa262c590c9fd66720f4a163420f447f4e1eaa94dd49d9
7
+ data.tar.gz: c9062ac547b6c76d1c4ea5cc384511e2e475c87c0d7cabf298ee6d4c61ef6b65912f47c832bbd86aee1d7cb73ce844971f846b96022f02629ecb7ca1b3d4f6c5
@@ -0,0 +1,19 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ jobs:
6
+ release:
7
+ permissions:
8
+ contents: write
9
+ id-token: write
10
+
11
+ name: Release
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: 3.3
18
+ bundler-cache: true
19
+ - 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,28 +1,49 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pgb_connection_reaper_rb (0.1.0)
4
+ pgb_connection_reaper_rb (0.2.1)
5
5
  activerecord (>= 4.2)
6
6
  activesupport (>= 4.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (7.0.8.2)
12
- activesupport (= 7.0.8.2)
13
- activerecord (7.0.8.2)
14
- activemodel (= 7.0.8.2)
15
- activesupport (= 7.0.8.2)
16
- activesupport (7.0.8.2)
11
+ activemodel (7.1.5.2)
12
+ activesupport (= 7.1.5.2)
13
+ activerecord (7.1.5.2)
14
+ activemodel (= 7.1.5.2)
15
+ activesupport (= 7.1.5.2)
16
+ timeout (>= 0.4.0)
17
+ activesupport (7.1.5.2)
18
+ base64
19
+ benchmark (>= 0.3)
20
+ bigdecimal
17
21
  concurrent-ruby (~> 1.0, >= 1.0.2)
22
+ connection_pool (>= 2.2.5)
23
+ drb
18
24
  i18n (>= 1.6, < 2)
25
+ logger (>= 1.4.2)
19
26
  minitest (>= 5.1)
27
+ mutex_m
28
+ securerandom (>= 0.3)
20
29
  tzinfo (~> 2.0)
21
- concurrent-ruby (1.2.3)
30
+ appraisal (2.5.0)
31
+ bundler
32
+ rake
33
+ thor (>= 0.14.0)
34
+ base64 (0.3.0)
35
+ benchmark (0.4.1)
36
+ bigdecimal (3.2.3)
37
+ concurrent-ruby (1.3.5)
38
+ connection_pool (2.5.4)
22
39
  diff-lcs (1.5.0)
23
- i18n (1.14.5)
40
+ drb (2.2.3)
41
+ i18n (1.14.7)
24
42
  concurrent-ruby (~> 1.0)
25
- minitest (5.23.1)
43
+ logger (1.7.0)
44
+ mini_portile2 (2.8.9)
45
+ minitest (5.25.5)
46
+ mutex_m (0.3.0)
26
47
  rake (12.3.3)
27
48
  rspec (3.12.0)
28
49
  rspec-core (~> 3.12.0)
@@ -37,6 +58,11 @@ GEM
37
58
  diff-lcs (>= 1.2.0, < 2.0)
38
59
  rspec-support (~> 3.12.0)
39
60
  rspec-support (3.12.0)
61
+ securerandom (0.4.1)
62
+ sqlite3 (1.7.3)
63
+ mini_portile2 (~> 2.8.0)
64
+ thor (1.4.0)
65
+ timeout (0.4.3)
40
66
  tzinfo (2.0.6)
41
67
  concurrent-ruby (~> 1.0)
42
68
 
@@ -44,9 +70,15 @@ PLATFORMS
44
70
  ruby
45
71
 
46
72
  DEPENDENCIES
73
+ appraisal (~> 2.4)
74
+ benchmark
75
+ bigdecimal
76
+ logger
77
+ mutex_m
47
78
  pgb_connection_reaper_rb!
48
79
  rake (~> 12.0)
49
80
  rspec (~> 3.0)
81
+ sqlite3 (~> 1.4)
50
82
 
51
83
  BUNDLED WITH
52
- 2.1.4
84
+ 2.7.2
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,8 +2,16 @@
2
2
 
3
3
  module PgbConnectionReaperRb
4
4
  module PostgreSQLAdapterExtension
5
- def reconnect!
6
- @lock.synchronize do
5
+ def reconnect!(**args)
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
7
15
  super
8
16
  disconnect!
9
17
  connect
@@ -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.1'
4
+ VERSION = '0.2.1'
5
5
  end
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'activerecord', '>= 4.2'
30
30
  spec.add_dependency 'activesupport', '>= 4.2'
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.1
4
+ version: 0.2.1
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-20 00:00:00.000000000 Z
11
+ date: 2025-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -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,13 @@ executables: []
59
73
  extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
76
+ - ".github/workflows/release.yml"
62
77
  - ".gitignore"
63
78
  - ".rspec"
64
79
  - ".rubocop.yml"
80
+ - ".tool-versions"
65
81
  - ".travis.yml"
82
+ - Appraisals
66
83
  - CODE_OF_CONDUCT.md
67
84
  - Gemfile
68
85
  - Gemfile.lock
@@ -100,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
117
  - !ruby/object:Gem::Version
101
118
  version: '0'
102
119
  requirements: []
103
- rubygems_version: 3.1.6
120
+ rubygems_version: 3.5.22
104
121
  signing_key:
105
122
  specification_version: 4
106
123
  summary: Gem for forcing cycling disconnections for Rails connections to PGBouncer