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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15b0d33ae1fec065fc2c2763f52bf5385da900ddbc3d8b55089ac6f1f99f9b1c
4
- data.tar.gz: 61de1ca1ad18611d9eb059dcec55eb85e4de55c965dd3ee33c60088a5d68f4f2
3
+ metadata.gz: 71d3927981244ea33e21fd09e315e4beef0427eb4dae56011484626ffb224346
4
+ data.tar.gz: 5596dbc4576f6cd9cd6ad3e1547ab8ff07d5fb33d3ee0688495fac14a0c50343
5
5
  SHA512:
6
- metadata.gz: 90e52914b1a63fbfb633882f60f2c2020a057b7ad16530c5800cc44f2e88d551c638fcdc31615f2c1c13d4fd031148ce568a10d4776c0082b0c917e9c7ee8dba
7
- data.tar.gz: 8b215a24c9c0e1ff79e75499b9d47976b0143095023c0ec2a1ab4c03cc5e9c048957ef63703fe2a8eef5b92c72b3d156a95662ac3367a67ec6324f9527142913
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
- @disallow_replica ||= 0
100
- @disallow_replica += 1 if which == :primary
99
+ self.disallow_replica += 1 if which == :primary
101
100
 
102
- switch_to_replica = force || @disallow_replica.zero?
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
- @disallow_replica -= 1 if which == :primary
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.2.0
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-11 00:00:00.000000000 Z
16
+ date: 2022-10-29 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activerecord