switchman 4.3.2 → 4.3.4
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/switchman/database_server.rb +8 -3
- data/lib/switchman/shard.rb +15 -3
- data/lib/switchman/version.rb +1 -1
- 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: 4c949cae7b5eb8457d2bd174b8546640c3692cdd13ded98eb907611400f6c822
|
|
4
|
+
data.tar.gz: 056763fe8e03d98d4d3bef4cf101bdfe51b2b66b2a9fa2bf796a40bbd6789949
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 526f97df24eaeea23324fcf6aaabe322256064a34d9071be36919881b8b3d787539e673455c4d1fdc4292dd64b5dfa09b910860975fc79e940698069bbe6bc1e
|
|
7
|
+
data.tar.gz: 609b4ee92ddea6bd07b0d79aa2a8c14fdfdcc3b8b7ce559941d919b881ba2921dbd9cfed662188050a16960b923d9bffbad910b42f4af1d7e34d09c292c747db
|
|
@@ -306,9 +306,14 @@ module Switchman
|
|
|
306
306
|
|
|
307
307
|
def primary_shard_id
|
|
308
308
|
unless instance_variable_defined?(:@primary_shard_id)
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
@primary_shard_id = Shard.default.activate do
|
|
310
|
+
Switchman.cache.fetch(["db_server_primary_shard_id", id]) do
|
|
311
|
+
# if sharding isn't fully set up yet, we may not be able to query the shards table
|
|
312
|
+
break Shard.default.id if Shard.default.database_server == self
|
|
313
|
+
|
|
314
|
+
shards.where(name: nil).first&.id
|
|
315
|
+
end
|
|
316
|
+
end
|
|
312
317
|
end
|
|
313
318
|
@primary_shard_id
|
|
314
319
|
end
|
data/lib/switchman/shard.rb
CHANGED
|
@@ -149,9 +149,18 @@ module Switchman
|
|
|
149
149
|
cached_shards[id]
|
|
150
150
|
end
|
|
151
151
|
|
|
152
|
-
def preload_cache
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
def preload_cache(shard_ids: nil)
|
|
153
|
+
if shard_ids
|
|
154
|
+
missing = shard_ids - cached_shards.keys
|
|
155
|
+
return if missing.empty?
|
|
156
|
+
|
|
157
|
+
found = where(id: missing).index_by(&:id)
|
|
158
|
+
missing.each { |id| found[id] = nil unless found.key?(id) } # cache nonexistence of shards
|
|
159
|
+
cached_shards.reverse_merge!(found)
|
|
160
|
+
else
|
|
161
|
+
cached_shards.reverse_merge!(active_shards.values.index_by(&:id))
|
|
162
|
+
cached_shards.reverse_merge!(all.index_by(&:id))
|
|
163
|
+
end
|
|
155
164
|
end
|
|
156
165
|
|
|
157
166
|
def clear_cache
|
|
@@ -672,6 +681,9 @@ module Switchman
|
|
|
672
681
|
Shard.default.activate do
|
|
673
682
|
Switchman.cache.delete(["shard", id].join("/"))
|
|
674
683
|
Switchman.cache.delete("default_shard") if default?
|
|
684
|
+
if database_server && (self[:name].nil? || name_before_last_save.nil?)
|
|
685
|
+
Switchman.cache.delete(["db_server_primary_shard_id", database_server.id])
|
|
686
|
+
end
|
|
675
687
|
end
|
|
676
688
|
self.class.clear_cache
|
|
677
689
|
end
|
data/lib/switchman/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: switchman
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.3.
|
|
4
|
+
version: 4.3.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cody Cutrer
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2026-
|
|
13
|
+
date: 2026-09-01 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activerecord
|