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 +4 -4
- data/lib/pgb_connection_reaper_rb/reaper.rb +18 -4
- data/lib/pgb_connection_reaper_rb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 572afe18ef474649611a89d55319a6dfd2889c404b5f81be1a8e3319bd1be2a2
|
4
|
+
data.tar.gz: 89f5fe8ef74bad4c3530a31adb380c9effaac7edbe31c2eeb35524945650b1bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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
|
29
|
-
|
30
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2024-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|