active_record_shards 5.2.0 → 5.3.0
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/active_record_shards/connection_switcher.rb +11 -4
- 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: 71d3927981244ea33e21fd09e315e4beef0427eb4dae56011484626ffb224346
|
|
4
|
+
data.tar.gz: 5596dbc4576f6cd9cd6ad3e1547ab8ff07d5fb33d3ee0688495fac14a0c50343
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6b430fc35baf8da887402d75e906cae36c2272e5e76076ee553f833423caf4059089298e2b4b002e826d99287fa5f31f69e9ed3d580370f1a9900c6dd0019de
|
|
7
|
+
data.tar.gz: f5bf02670f7ace64c734d3a5ef8e008395067b23451b61ea55a2bfb2b207c4ea20bc5225d7dd8230bbd73b223639079bdf3e0e7267ff1d94636cf6dc68702d48
|
|
@@ -96,10 +96,9 @@ module ActiveRecordShards
|
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
def on_cx_switch_block(which, force: false, construct_ro_scope: nil, &block)
|
|
99
|
-
|
|
100
|
-
@disallow_replica += 1 if which == :primary
|
|
99
|
+
self.disallow_replica += 1 if which == :primary
|
|
101
100
|
|
|
102
|
-
switch_to_replica = force ||
|
|
101
|
+
switch_to_replica = force || disallow_replica.zero?
|
|
103
102
|
old_options = current_shard_selection.options
|
|
104
103
|
|
|
105
104
|
switch_connection(replica: switch_to_replica)
|
|
@@ -112,10 +111,18 @@ module ActiveRecordShards
|
|
|
112
111
|
readonly.scoping(&block)
|
|
113
112
|
end
|
|
114
113
|
ensure
|
|
115
|
-
|
|
114
|
+
self.disallow_replica -= 1 if which == :primary
|
|
116
115
|
switch_connection(old_options) if old_options
|
|
117
116
|
end
|
|
118
117
|
|
|
118
|
+
def disallow_replica=(value)
|
|
119
|
+
Thread.current[:__active_record_shards__disallow_replica_by_thread] = value
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def disallow_replica
|
|
123
|
+
Thread.current[:__active_record_shards__disallow_replica_by_thread] ||= 0
|
|
124
|
+
end
|
|
125
|
+
|
|
119
126
|
def supports_sharding?
|
|
120
127
|
shard_names.any?
|
|
121
128
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_record_shards
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Benjamin Quorning
|
|
@@ -13,7 +13,7 @@ authors:
|
|
|
13
13
|
autorequire:
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
|
-
date: 2022-10-
|
|
16
|
+
date: 2022-10-29 00:00:00.000000000 Z
|
|
17
17
|
dependencies:
|
|
18
18
|
- !ruby/object:Gem::Dependency
|
|
19
19
|
name: activerecord
|