replica_pools 2.5.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/replica_pools/connection_proxy.rb +5 -5
- data/lib/replica_pools/pools.rb +12 -10
- data/lib/replica_pools/query_cache.rb +4 -4
- data/lib/replica_pools/version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da0145ee587f2856d0ba448914437caf148e8825abc9e2b31a853e8c6585ffdb
|
4
|
+
data.tar.gz: 26ffb29f8c44dcaefa6f0ba16452ab4af4757c46e1f660d76f6e3906cc2edb06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70883d9c60ccfc07230b262af71c476d2944321e371a6bbdc4ba873eefe17e49e9185ac1bae7a95b30f51f6874b2a8d313fe2b35dc3b9c3253918b590d8a5798
|
7
|
+
data.tar.gz: c47b4975d6bbc30e44602ed51a60ea9d827624b3dabf726ad54d21524691e8acbf78545d7b1afecf5322d5122fce2a908b0461a68f6411a0f16e058354356c64
|
@@ -64,8 +64,8 @@ module ReplicaPools
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
def transaction(
|
68
|
-
with_leader { leader.transaction(
|
67
|
+
def transaction(...)
|
68
|
+
with_leader { leader.transaction(...) }
|
69
69
|
end
|
70
70
|
|
71
71
|
def next_replica!
|
@@ -86,9 +86,9 @@ module ReplicaPools
|
|
86
86
|
# Proxies any unknown methods to leader.
|
87
87
|
# Safe methods have been generated during `setup!`.
|
88
88
|
# Creates a method to speed up subsequent calls.
|
89
|
-
def method_missing(method, *args, &block)
|
90
|
-
self.class.define_method(method) do |*args, &block|
|
91
|
-
route_to(leader, method, *args, &block).tap do
|
89
|
+
def method_missing(method, *args, **kwargs, &block)
|
90
|
+
self.class.define_method(method) do |*args, **kwargs, &block|
|
91
|
+
route_to(leader, method, *args, **kwargs, &block).tap do
|
92
92
|
if %i[insert delete update].include?(method)
|
93
93
|
leader.retrieve_connection.clear_query_cache
|
94
94
|
end
|
data/lib/replica_pools/pools.rb
CHANGED
@@ -34,18 +34,20 @@ module ReplicaPools
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def config_hash
|
37
|
-
if ActiveRecord::VERSION::MAJOR
|
38
|
-
# in Rails = 7, ActiveRecord::Base.configurations.to_h has been deprecated
|
39
|
-
ActiveRecord::Base.configurations.configs_for.map do |c|
|
40
|
-
[c.env_name, c.configuration_hash.transform_keys(&:to_s)]
|
41
|
-
end.to_h
|
42
|
-
elsif ActiveRecord::VERSION::MAJOR == 6
|
43
|
-
# in Rails = 6, `configurations` is an instance of ActiveRecord::DatabaseConfigurations
|
44
|
-
ActiveRecord::Base.configurations.to_h
|
45
|
-
else
|
37
|
+
if ActiveRecord::VERSION::MAJOR < 6
|
46
38
|
# in Rails < 6, it's just a hash
|
47
|
-
ActiveRecord::Base.configurations
|
39
|
+
return ActiveRecord::Base.configurations
|
48
40
|
end
|
41
|
+
|
42
|
+
if ActiveRecord::VERSION::MAJOR == 6 && ActiveRecord::VERSION::MINOR < 1
|
43
|
+
# in Rails = 6.0, `configurations` is an instance of ActiveRecord::DatabaseConfigurations
|
44
|
+
return ActiveRecord::Base.configurations.to_h
|
45
|
+
end
|
46
|
+
|
47
|
+
# in Rails >= 6.1, ActiveRecord::Base.configurations.to_h has been deprecated
|
48
|
+
ActiveRecord::Base.configurations.configs_for.map do |c|
|
49
|
+
[c.env_name, c.configuration_hash.transform_keys(&:to_s)]
|
50
|
+
end.to_h
|
49
51
|
end
|
50
52
|
|
51
53
|
# generates a unique ActiveRecord::Base subclass for a single replica
|
@@ -18,11 +18,11 @@ 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)
|
21
|
+
def select_all(*args, **kwargs)
|
22
22
|
relation, name, raw_binds = args
|
23
23
|
|
24
24
|
if !query_cache_enabled || locked?(relation)
|
25
|
-
return route_to(current, :select_all, *args)
|
25
|
+
return route_to(current, :select_all, *args, **kwargs)
|
26
26
|
end
|
27
27
|
|
28
28
|
# duplicate binds_from_relation behavior introduced in 4.2.
|
@@ -38,9 +38,9 @@ module ReplicaPools
|
|
38
38
|
args[2] = binds
|
39
39
|
|
40
40
|
if Gem::Version.new(ActiveRecord.version) < Gem::Version.new('5.1')
|
41
|
-
cache_sql(sql, binds) { route_to(current, :select_all, *args) }
|
41
|
+
cache_sql(sql, binds) { route_to(current, :select_all, *args, **kwargs) }
|
42
42
|
else
|
43
|
-
cache_sql(sql, name, binds) { route_to(current, :select_all, *args) }
|
43
|
+
cache_sql(sql, name, binds) { route_to(current, :select_all, *args, **kwargs) }
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: replica_pools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Drabik
|
8
8
|
- Lance Ivy
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-04-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -143,7 +143,7 @@ homepage: https://github.com/kickstarter/replica_pools
|
|
143
143
|
licenses:
|
144
144
|
- MIT
|
145
145
|
metadata: {}
|
146
|
-
post_install_message:
|
146
|
+
post_install_message:
|
147
147
|
rdoc_options: []
|
148
148
|
require_paths:
|
149
149
|
- lib
|
@@ -151,21 +151,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
151
|
requirements:
|
152
152
|
- - ">="
|
153
153
|
- !ruby/object:Gem::Version
|
154
|
-
version:
|
154
|
+
version: 2.7.0
|
155
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '1.2'
|
160
160
|
requirements: []
|
161
|
-
rubygems_version: 3.
|
162
|
-
signing_key:
|
161
|
+
rubygems_version: 3.1.6
|
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/
|
167
|
-
- spec/connection_proxy_spec.rb
|
166
|
+
- spec/spec_helper.rb
|
168
167
|
- spec/pool_spec.rb
|
169
|
-
- spec/query_cache_spec.rb
|
170
168
|
- spec/slave_pools_spec.rb
|
171
|
-
- spec/
|
169
|
+
- spec/config/test_model.rb
|
170
|
+
- spec/query_cache_spec.rb
|
171
|
+
- spec/connection_proxy_spec.rb
|