pgb_connection_reaper_rb 0.1.0 → 0.1.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: 569b771b3f4350ebf2fd979525dbe1823bd008d094116056291a86d701cf9fdb
4
- data.tar.gz: 29b698807ee595d91025dd69153df2df9397f725ef3219ceac33e5326e868b49
3
+ metadata.gz: 572afe18ef474649611a89d55319a6dfd2889c404b5f81be1a8e3319bd1be2a2
4
+ data.tar.gz: 89f5fe8ef74bad4c3530a31adb380c9effaac7edbe31c2eeb35524945650b1bc
5
5
  SHA512:
6
- metadata.gz: c9de9d77a18a19f314123b1d2810dfdda78fd2287f2c59b03e1e8050585ef7eb6ae6b43e80a9ebe47afa93bec301b699863aaa2457463e060aa5176408969744
7
- data.tar.gz: a4c4d0208f843c30170be8e967051866eacb259f7d22e6cda80a3f2f1f83903733ed1c398c44b2c827eab29ef2d6f5d1ffcbaf2100e0eaa4fdaba993e675daea
6
+ metadata.gz: 41ec26720b292406771b9efed8ed88ac9442042caa62f753c763e4079d5864e55f6b5099910255455b96853e9e78839205e1a461fad9f1d42249ef0e299d227a
7
+ data.tar.gz: fe22aff3a0c69b48668b30c4bd667de385bd301e25a07cba073cdcc0efc5e6cbe8798f0f2971cbdb030830e7c58a644bc09f5849628c0823093b603da38f1f7e
@@ -6,8 +6,10 @@ module PgbConnectionReaperRb
6
6
  module Reaper
7
7
  def initialize(*args)
8
8
  super
9
+
10
+ config = get_db_config
9
11
  @connected_at = Concurrent.monotonic_time
10
- @pgb_ttl = self.class.type_cast_config_to_integer(@config.fetch(:pgb_ttl, nil))
12
+ @pgb_ttl = self.class.type_cast_config_to_integer(config.fetch(:pgb_ttl, nil))
11
13
  end
12
14
 
13
15
  attr_reader :connected_at, :pgb_ttl
@@ -17,6 +19,13 @@ module PgbConnectionReaperRb
17
19
  @connected_at = Concurrent.monotonic_time
18
20
  end
19
21
 
22
+ def verify!(*args)
23
+ super(*args)
24
+ reconnect! if eligible?
25
+ end
26
+
27
+ private
28
+
20
29
  def age
21
30
  Concurrent.monotonic_time - @connected_at
22
31
  end
@@ -25,9 +34,14 @@ module PgbConnectionReaperRb
25
34
  pgb_ttl && age > pgb_ttl
26
35
  end
27
36
 
28
- def verify!(*args)
29
- super(*args)
30
- reconnect! if eligible?
37
+ def get_db_config
38
+ if ActiveRecord::Base.respond_to?(:connection_db_config)
39
+ ActiveRecord::Base.connection_db_config.configuration_hash
40
+ else
41
+ ActiveRecord::Base.connection_config
42
+ end
43
+ rescue
44
+ {}
31
45
  end
32
46
  end
33
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgbConnectionReaperRb
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  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.0
4
+ version: 0.1.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-10-08 00:00:00.000000000 Z
11
+ date: 2024-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord