active_record_host_pool 1.1.1 → 1.2.1
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: 6c8a74e78b05f5094b89403c7e77ebbe40802ebeeec9f8ea724cdf3527c20dea
|
4
|
+
data.tar.gz: 8e8e5c3ba32256bcf5c39e974bb8565ae464bad9aafa41d0ad5309802d226dc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3c9ed0921dae7152f1de4e498edd761960b81038c8d46a32674949fe152d8dd2b9ad8a836322d8cabf6f05a3484e9297a535553dc8c888109958fdb00eacea9
|
7
|
+
data.tar.gz: fcb8f19f314456e8dc293a6233650723da2f6bad8548fba12671827d12bd1c3842cb555d2b2ca413488cadf9099b8b491b01ef256279099a3a3a0473b4507701
|
@@ -32,11 +32,12 @@ module ActiveRecordHostPool
|
|
32
32
|
super
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
35
|
+
def self.ruby2_keywords(*); end unless respond_to?(:ruby2_keywords, true)
|
36
|
+
ruby2_keywords def execute_with_switching(*args, **kwargs)
|
36
37
|
if _host_pool_current_database && !_no_switch
|
37
38
|
_switch_connection
|
38
39
|
end
|
39
|
-
execute_without_switching(*args)
|
40
|
+
execute_without_switching(*args, **kwargs)
|
40
41
|
end
|
41
42
|
|
42
43
|
def drop_database_with_no_switching(*args)
|
@@ -97,7 +98,7 @@ module ActiveRecord
|
|
97
98
|
module ConnectionAdapters
|
98
99
|
class ConnectionHandler
|
99
100
|
case "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"
|
100
|
-
when '6.1'
|
101
|
+
when '6.1', '7.0'
|
101
102
|
|
102
103
|
:noop
|
103
104
|
|
@@ -122,6 +123,7 @@ ActiveRecord::ConnectionAdapters::Mysql2Adapter.include(ActiveRecordHostPool::Da
|
|
122
123
|
|
123
124
|
# In Rails 6.1 Connection Pools are no longer instantiated in #establish_connection but in a
|
124
125
|
# new pool method.
|
125
|
-
|
126
|
+
case "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"
|
127
|
+
when '6.1', '7.0'
|
126
128
|
ActiveRecord::ConnectionAdapters::PoolConfig.prepend(ActiveRecordHostPool::PoolConfigPatch)
|
127
129
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
case "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"
|
4
|
+
when '6.1', '7.0'
|
4
5
|
require 'active_record_host_pool/pool_proxy_6_1'
|
5
6
|
else
|
6
7
|
require 'active_record_host_pool/pool_proxy_legacy'
|
data/test/helper.rb
CHANGED
@@ -5,7 +5,7 @@ require 'minitest/autorun'
|
|
5
5
|
|
6
6
|
require 'active_record_host_pool'
|
7
7
|
require 'logger'
|
8
|
-
require '
|
8
|
+
require 'minitest/mock_expectations'
|
9
9
|
require 'phenix'
|
10
10
|
|
11
11
|
ENV['RAILS_ENV'] = 'test'
|
@@ -20,6 +20,8 @@ RAILS_6_1_WITH_NON_LEGACY_CONNECTION_HANDLING =
|
|
20
20
|
|
21
21
|
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + '/test.log')
|
22
22
|
|
23
|
+
Thread.abort_on_exception = true
|
24
|
+
|
23
25
|
# BEGIN preventing_writes? patch
|
24
26
|
## Rails 6.1 by default does not allow writing to replica databases which prevents
|
25
27
|
## us from properly setting up the test databases. This patch is used in test/schema.rb
|
data/test/test_arhp.rb
CHANGED
@@ -122,18 +122,22 @@ class ActiveRecordHostPoolTest < Minitest::Test
|
|
122
122
|
|
123
123
|
def test_no_switch_when_creating_db
|
124
124
|
conn = Pool1DbA.connection
|
125
|
-
conn
|
126
|
-
|
127
|
-
|
128
|
-
|
125
|
+
assert_called(conn, :execute_without_switching) do
|
126
|
+
refute_called(conn, :_switch_connection) do
|
127
|
+
assert conn._host_pool_current_database
|
128
|
+
conn.create_database(:some_args)
|
129
|
+
end
|
130
|
+
end
|
129
131
|
end
|
130
132
|
|
131
133
|
def test_no_switch_when_dropping_db
|
132
134
|
conn = Pool1DbA.connection
|
133
|
-
conn
|
134
|
-
|
135
|
-
|
136
|
-
|
135
|
+
assert_called(conn, :execute_without_switching) do
|
136
|
+
refute_called(conn, :_switch_connection) do
|
137
|
+
assert conn._host_pool_current_database
|
138
|
+
conn.drop_database(:some_args)
|
139
|
+
end
|
140
|
+
end
|
137
141
|
end
|
138
142
|
|
139
143
|
def test_underlying_assumption_about_test_db
|
@@ -163,8 +167,9 @@ class ActiveRecordHostPoolTest < Minitest::Test
|
|
163
167
|
thread_id = switch_to_klass.connection.select_value('select @@pseudo_thread_id')
|
164
168
|
|
165
169
|
# now, disable our auto-switching and trigger a mysql reconnect
|
166
|
-
switch_to_klass.connection.unproxied.
|
167
|
-
|
170
|
+
switch_to_klass.connection.unproxied.stub(:_switch_connection, true) do
|
171
|
+
Pool2DbD.connection.execute("KILL #{thread_id}")
|
172
|
+
end
|
168
173
|
|
169
174
|
# and finally, did mysql reconnect correctly?
|
170
175
|
puts "\nAnd now we end up on #{current_database(switch_to_klass)}" if debug_me
|
@@ -174,7 +179,8 @@ class ActiveRecordHostPoolTest < Minitest::Test
|
|
174
179
|
def test_release_connection
|
175
180
|
pool = ActiveRecord::Base.connection_pool
|
176
181
|
conn = pool.connection
|
177
|
-
pool
|
178
|
-
|
182
|
+
assert_called_with(pool, :checkin, [conn]) do
|
183
|
+
pool.release_connection
|
184
|
+
end
|
179
185
|
end
|
180
186
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_host_pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Quorning
|
8
8
|
- Gabe Martin-Dempesy
|
9
9
|
- Pierre Schambacher
|
10
10
|
- Ben Osheroff
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-
|
14
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activerecord
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: 5.1.0
|
23
23
|
- - "<"
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: '7.
|
25
|
+
version: '7.1'
|
26
26
|
type: :runtime
|
27
27
|
prerelease: false
|
28
28
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 5.1.0
|
33
33
|
- - "<"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '7.
|
35
|
+
version: '7.1'
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mysql2
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,19 +76,19 @@ dependencies:
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 5.10.0
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
79
|
+
name: minitest-mock_expectations
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- - "
|
82
|
+
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: 1.
|
84
|
+
version: 1.1.3
|
85
85
|
type: :development
|
86
86
|
prerelease: false
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- - "
|
89
|
+
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: 1.
|
91
|
+
version: 1.1.3
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: phenix
|
94
94
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,20 +131,6 @@ dependencies:
|
|
131
131
|
- - "~>"
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: 0.80.0
|
134
|
-
- !ruby/object:Gem::Dependency
|
135
|
-
name: shoulda
|
136
|
-
requirement: !ruby/object:Gem::Requirement
|
137
|
-
requirements:
|
138
|
-
- - ">="
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: '0'
|
141
|
-
type: :development
|
142
|
-
prerelease: false
|
143
|
-
version_requirements: !ruby/object:Gem::Requirement
|
144
|
-
requirements:
|
145
|
-
- - ">="
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
version: '0'
|
148
134
|
description: ''
|
149
135
|
email:
|
150
136
|
- bquorning@zendesk.com
|
@@ -174,7 +160,7 @@ homepage: https://github.com/zendesk/active_record_host_pool
|
|
174
160
|
licenses:
|
175
161
|
- MIT
|
176
162
|
metadata: {}
|
177
|
-
post_install_message:
|
163
|
+
post_install_message:
|
178
164
|
rdoc_options: []
|
179
165
|
require_paths:
|
180
166
|
- lib
|
@@ -189,8 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
175
|
- !ruby/object:Gem::Version
|
190
176
|
version: '0'
|
191
177
|
requirements: []
|
192
|
-
rubygems_version: 3.1
|
193
|
-
signing_key:
|
178
|
+
rubygems_version: 3.0.3.1
|
179
|
+
signing_key:
|
194
180
|
specification_version: 4
|
195
181
|
summary: Allow ActiveRecord to share a connection to multiple databases on the same
|
196
182
|
host
|