replica_pools 2.6.4 → 2.6.6
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/README.md +12 -11
- data/lib/replica_pools/connection_proxy.rb +2 -5
- data/lib/replica_pools/query_cache.rb +9 -18
- data/lib/replica_pools/version.rb +1 -1
- data/spec/query_cache_spec.rb +12 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d922bbdd8ecbc6f8738bad680376d89886018b681fbfc7df10cc082ae3f475e4
|
4
|
+
data.tar.gz: 7d89312f16e3e172b10b7b08c63c8a11c546782d790ef3d7492992926a8cca3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dbcdf906d0dae7171c64e250b11805817595316ad6ce877214856c4b5be71594d218c16f1df99ed8c362db07a7b9981950e3f90d45e4d9238383c33cdec445f
|
7
|
+
data.tar.gz: ba7f78a5e3f0e4ca562232f914c161544aa51a1a873ab74eb37af4badf905e3000c7e4bd33f984bb9bfcf66879b94c763e165e33026c07bde2ddbdda94a07c50
|
data/README.md
CHANGED
@@ -173,21 +173,22 @@ Tests are run against MySQL 5.6 using docker-compose. 🐋
|
|
173
173
|
|
174
174
|
To get set up, first run:
|
175
175
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
$ bundle exec rake bootstrap
|
180
|
-
```
|
176
|
+
docker-compose up
|
177
|
+
bundle install
|
178
|
+
bundle exec rake bootstrap
|
181
179
|
|
182
180
|
Then you can run tests with:
|
183
181
|
|
184
|
-
|
185
|
-
$ bundle exec rake spec
|
186
|
-
```
|
182
|
+
bundle exec rake spec
|
187
183
|
|
188
184
|
## Releasing a New Version
|
189
185
|
|
190
|
-
|
186
|
+
Follow these steps to publish a new version to RubyGems:
|
187
|
+
|
188
|
+
1. Increment the version in [lib/replica_pools/version.rb](./lib/replica_pools/version.rb). We follow [Semantic Versioning](http://semver.org).
|
189
|
+
2. Push changes to GitHub
|
190
|
+
3. Create a [new release](https://github.com/kickstarter/replica_pools/releases)
|
191
|
+
4. Ensure the [Test and Release](https://github.com/kickstarter/replica_pools/actions/workflows/test-release.yml) GitHub Action succeeds in pushing a new gem to RubyGems
|
191
192
|
|
192
193
|
## Authors
|
193
194
|
|
@@ -203,10 +204,10 @@ Released under the MIT license
|
|
203
204
|
|
204
205
|
The project is based on:
|
205
206
|
|
206
|
-
- https://github.com/schoefmax/multi_db
|
207
|
+
- [github.com/schoefmax/multi_db](https://github.com/schoefmax/multi_db)
|
207
208
|
|
208
209
|
### Masochism
|
209
210
|
|
210
211
|
The original leader/replica plugin:
|
211
212
|
|
212
|
-
- http://github.com/technoweenie/masochism
|
213
|
+
- [github.com/technoweenie/masochism](http://github.com/technoweenie/masochism)
|
@@ -100,7 +100,7 @@ module ReplicaPools
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
103
|
-
send(method, *args, &block)
|
103
|
+
send(method, *args, **kwargs, &block)
|
104
104
|
end
|
105
105
|
|
106
106
|
def within_leader_block?
|
@@ -109,10 +109,7 @@ module ReplicaPools
|
|
109
109
|
|
110
110
|
def route_to(conn, method, *args, **keyword_args, &block)
|
111
111
|
raise ReplicaPools::LeaderDisabled.new if ReplicaPools.config.disable_leader && conn == leader
|
112
|
-
|
113
|
-
|
114
|
-
connection.verify!
|
115
|
-
connection.send(method, *args, **keyword_args, &block)
|
112
|
+
conn.retrieve_connection.send(method, *args, **keyword_args, &block)
|
116
113
|
rescue => e
|
117
114
|
ReplicaPools.log :error, "Error during ##{method}: #{e}"
|
118
115
|
log_proxy_state
|
@@ -18,29 +18,20 @@ module ReplicaPools
|
|
18
18
|
# select_all is trickier. it needs to use the leader
|
19
19
|
# connection for cache logic, but ultimately pass its query
|
20
20
|
# through to whatever connection is current.
|
21
|
-
def select_all(*args, **kwargs)
|
22
|
-
|
23
|
-
|
24
|
-
if !query_cache_enabled || locked?(relation)
|
25
|
-
return route_to(current, :select_all, *args, **kwargs)
|
21
|
+
def select_all(arel, name = nil, binds = [], *args, preparable: nil, **kwargs)
|
22
|
+
if !query_cache_enabled || locked?(arel)
|
23
|
+
return route_to(current, :select_all, arel, name, binds, *args, preparable: preparable, **kwargs)
|
26
24
|
end
|
27
25
|
|
28
|
-
# duplicate
|
29
|
-
if
|
30
|
-
arel
|
31
|
-
else
|
32
|
-
arel, binds = relation, Array(raw_binds)
|
26
|
+
# duplicate arel_from_relation behavior introduced in 5.2.
|
27
|
+
if arel.is_a?(ActiveRecord::Relation)
|
28
|
+
arel = arel.arel
|
33
29
|
end
|
34
30
|
|
35
|
-
sql =
|
36
|
-
|
37
|
-
args[0] = sql
|
38
|
-
args[2] = binds
|
31
|
+
sql, binds, preparable = to_sql_and_binds(arel, binds, preparable)
|
39
32
|
|
40
|
-
|
41
|
-
|
42
|
-
else
|
43
|
-
cache_sql(sql, name, binds) { route_to(current, :select_all, *args, **kwargs) }
|
33
|
+
cache_sql(sql, name, binds) do
|
34
|
+
route_to(current, :select_all, arel, name, binds, *args, preparable: preparable, **kwargs)
|
44
35
|
end
|
45
36
|
end
|
46
37
|
|
data/spec/query_cache_spec.rb
CHANGED
@@ -116,4 +116,16 @@ describe ReplicaPools::QueryCache do
|
|
116
116
|
expect(TestModel.pluck(:id).count).to eql TestModel.all.count
|
117
117
|
end
|
118
118
|
end
|
119
|
+
|
120
|
+
describe '.ids regression test' do
|
121
|
+
it 'should work with query caching' do
|
122
|
+
TestModel.connection.enable_query_cache!
|
123
|
+
expect(TestModel.ids.count).to eql TestModel.all.count
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should work if query cache is not enabled' do
|
127
|
+
TestModel.connection.disable_query_cache!
|
128
|
+
expect(TestModel.ids.count).to eql TestModel.all.count
|
129
|
+
end
|
130
|
+
end
|
119
131
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: replica_pools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Drabik
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -158,14 +158,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '1.2'
|
160
160
|
requirements: []
|
161
|
-
rubygems_version: 3.
|
161
|
+
rubygems_version: 3.4.10
|
162
162
|
signing_key:
|
163
163
|
specification_version: 4
|
164
164
|
summary: Connection proxy for ActiveRecord for leader / replica setups.
|
165
165
|
test_files:
|
166
|
-
- spec/spec_helper.rb
|
167
|
-
- spec/pool_spec.rb
|
168
|
-
- spec/slave_pools_spec.rb
|
169
166
|
- spec/config/test_model.rb
|
170
|
-
- spec/query_cache_spec.rb
|
171
167
|
- spec/connection_proxy_spec.rb
|
168
|
+
- spec/pool_spec.rb
|
169
|
+
- spec/query_cache_spec.rb
|
170
|
+
- spec/slave_pools_spec.rb
|
171
|
+
- spec/spec_helper.rb
|