active_record_host_pool 3.2.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8149f10e7b7b05c8ce36cb00ee2c0a77c6df40df5e594eb66cdcfbd42c265ddf
|
4
|
+
data.tar.gz: d9464ea5f9f1d310259c54b22d0d7df40c8b04d0a0568d378893174861675f7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5454f3f23ffd85a74e0fea41588b4b4093578893dfbf4d4c7e25a18b05ea45749249acbf9cb0755d1921c37c2e3016c8ec006171c21d4e8f79cee25488c0ba2
|
7
|
+
data.tar.gz: c8e2aa410f402b5272d37fd2c6e0405b4771469325c660e865f22a8adffcb0d6f9a1c574bab9952b81c81ef0186df9884042e35564a91cdc23b89ba5bf85f120
|
data/Changelog.md
CHANGED
@@ -6,6 +6,15 @@ and as of v1.0.0 this project adheres to [Semantic Versioning](https://semver.or
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [4.0.0]
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
- Moved `select_db` inside of the `with_raw_connection` block of the `#raw_execute` method. This should allow for using Rails' built-in reconnect & retry logic with the Trilogy adapter or Rails 7.1+.
|
13
|
+
- In Rails 7.1+, when a new ConnectionProxy is instantiated the database switch is lazily triggered by the subsequent database query instead of immediately.
|
14
|
+
|
15
|
+
### Removed
|
16
|
+
- Calling `#clean!` and `#verified!` on connections because it is no longer necessary.
|
17
|
+
|
9
18
|
## [3.2.0]
|
10
19
|
|
11
20
|
### Added
|
@@ -28,20 +28,23 @@ module ActiveRecordHostPool
|
|
28
28
|
@config[:database] = _host_pool_desired_database
|
29
29
|
end
|
30
30
|
|
31
|
-
if ActiveRecord.version >= Gem::Version.new("7.1")
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
if ActiveRecord.version >= Gem::Version.new("7.1")
|
32
|
+
def with_raw_connection(...)
|
33
|
+
super do |real_connection|
|
34
|
+
_switch_connection(real_connection) if _host_pool_desired_database && !_no_switch
|
35
|
+
yield real_connection
|
36
|
+
end
|
37
|
+
end
|
38
|
+
elsif ActiveRecordHostPool.loaded_db_adapter == :trilogy
|
39
|
+
def with_trilogy_connection(...)
|
40
|
+
super do |real_connection|
|
41
|
+
_switch_connection(real_connection) if _host_pool_desired_database && !_no_switch
|
42
|
+
yield real_connection
|
37
43
|
end
|
38
|
-
super
|
39
44
|
end
|
40
45
|
else
|
41
46
|
def execute(...)
|
42
|
-
if _host_pool_desired_database && !_no_switch
|
43
|
-
_switch_connection
|
44
|
-
end
|
47
|
+
_switch_connection(raw_connection) if _host_pool_desired_database && !_no_switch
|
45
48
|
super
|
46
49
|
end
|
47
50
|
end
|
@@ -70,7 +73,7 @@ module ActiveRecordHostPool
|
|
70
73
|
|
71
74
|
attr_accessor :_no_switch
|
72
75
|
|
73
|
-
def _switch_connection
|
76
|
+
def _switch_connection(real_connection)
|
74
77
|
if _host_pool_desired_database &&
|
75
78
|
(
|
76
79
|
_desired_database_changed? ||
|
@@ -78,11 +81,7 @@ module ActiveRecordHostPool
|
|
78
81
|
)
|
79
82
|
log("select_db #{_host_pool_desired_database}", "SQL") do
|
80
83
|
clear_cache!
|
81
|
-
|
82
|
-
if respond_to?(:clean!)
|
83
|
-
clean!
|
84
|
-
verified!
|
85
|
-
end
|
84
|
+
real_connection.select_db(_host_pool_desired_database)
|
86
85
|
end
|
87
86
|
@_cached_current_database = _host_pool_desired_database
|
88
87
|
@_cached_connection_object_id = _real_connection_object_id
|
@@ -219,12 +219,7 @@ module ActiveRecordHostPool
|
|
219
219
|
@connection_proxy_cache ||= {}
|
220
220
|
key = [connection, database]
|
221
221
|
|
222
|
-
@connection_proxy_cache[key] ||=
|
223
|
-
cx = ActiveRecordHostPool::ConnectionProxy.new(connection, database)
|
224
|
-
cx.raw_execute("SELECT 1", "ARHP SWITCH DB")
|
225
|
-
|
226
|
-
cx
|
227
|
-
end
|
222
|
+
@connection_proxy_cache[key] ||= ActiveRecordHostPool::ConnectionProxy.new(connection, database)
|
228
223
|
end
|
229
224
|
end
|
230
225
|
# standard:enable Lint/DuplicateMethods
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_host_pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Quorning
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2024-09-
|
14
|
+
date: 2024-09-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activerecord
|