switchman 4.3.3 → 4.3.5

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: 4437e8d734e3c009a9d46806e1030d9afa36701db8999c28c9892e2db7b1171e
4
- data.tar.gz: 10cbc99e69f2a32d87a9f3c0b19d183124aeb2c10ddd88575a8f0dec86125efb
3
+ metadata.gz: 756e8de301a68ac11f33a55bf4686cfa5deb9ff15f40b8750a9ec9ade881e136
4
+ data.tar.gz: 347370745f986e5b63bcc2c11c8855d5ca1a9c08d79e0f8b66d60552b0cbaa1b
5
5
  SHA512:
6
- metadata.gz: 516ded0cd496113906deefabc1a05908d0ac865913c790cf92e26b665b60617b56221952d84936bdbf9ffef48ab5d0fa66425575c85c0448b19f0d35725afd3d
7
- data.tar.gz: 26c13f7b3915f62c92506b68814888374d00eb4a20e982fd038cf962675a7de2df4188a8c8fbcdeffe7caddb3d68e1c1fd5f92ad29949c72889d594c9e93d47d
6
+ metadata.gz: 6f50f01e9566f118a4bbc89a4aa30fabc8ed00d34fc020c84856ab5c027aa912b57462c7a5658f7b330eaed4308d121703266f441b9b1e451dcf4a2bf3e8ee3e
7
+ data.tar.gz: 3146ef11b0fa04471c63c0bc74bb4344d15fc08a833bfbd878a5be82cfd024a2f6c2516bef2961e8032164f16db367c2b96aaf421032d2b7e10b4a3e599b00eb
@@ -306,9 +306,14 @@ module Switchman
306
306
 
307
307
  def primary_shard_id
308
308
  unless instance_variable_defined?(:@primary_shard_id)
309
- # if sharding isn't fully set up yet, we may not be able to query the shards table
310
- @primary_shard_id = Shard.default.id if Shard.default.database_server == self
311
- @primary_shard_id ||= shards.where(name: nil).first&.id
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
@@ -154,12 +154,12 @@ module Switchman
154
154
  missing = shard_ids - cached_shards.keys
155
155
  return if missing.empty?
156
156
 
157
- found = where(id: missing).index_by(&:id)
157
+ found = where(id: missing).select(&:database_server).index_by(&:id) # exclude shards w/o database servers
158
158
  missing.each { |id| found[id] = nil unless found.key?(id) } # cache nonexistence of shards
159
159
  cached_shards.reverse_merge!(found)
160
160
  else
161
161
  cached_shards.reverse_merge!(active_shards.values.index_by(&:id))
162
- cached_shards.reverse_merge!(all.index_by(&:id))
162
+ cached_shards.reverse_merge!(all.select(&:database_server).index_by(&:id))
163
163
  end
164
164
  end
165
165
 
@@ -681,6 +681,9 @@ module Switchman
681
681
  Shard.default.activate do
682
682
  Switchman.cache.delete(["shard", id].join("/"))
683
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
684
687
  end
685
688
  self.class.clear_cache
686
689
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "4.3.3"
4
+ VERSION = "4.3.5"
5
5
  end
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.3
4
+ version: 4.3.5
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-08-26 00:00:00.000000000 Z
13
+ date: 2026-09-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord