switchman 4.3.8 → 4.3.9
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/engine.rb +2 -1
- data/lib/switchman/shard.rb +16 -5
- 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: 4d54cb405479d21db976021502058d0a19ff90c7c7defb474159353957149cd8
|
|
4
|
+
data.tar.gz: a4a42a4b2f47f95282db95a2e385212161754bbb404f972059c3b69f8fa786d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d6d48cdef1bde0c6fa498829f112ed4196c66e82c424c9f2a3e7fadf1043617394c343de809a9e80af6ddbc9d098b9e08d0b6b41260a43d77cb62574494277d0
|
|
7
|
+
data.tar.gz: a0ce1835343dabeb7829023b3b673451a9489bbc81211aaf2128c885d80525d2dc0c8b4810cb52d6022ddecf82c02415e1632f3a79e5255cc67e28327d0c34cc
|
data/lib/switchman/engine.rb
CHANGED
|
@@ -95,6 +95,8 @@ module Switchman
|
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
::ActiveRecord::ConnectionAdapters::TableDefinition.prepend(ActiveRecord::TableDefinition)
|
|
98
|
+
|
|
99
|
+
::ActiveRecord::TestFixtures.prepend(ActiveRecord::TestFixtures) # rubocop:disable Rails/ActiveSupportOnLoad
|
|
98
100
|
end
|
|
99
101
|
|
|
100
102
|
::ActiveSupport.on_load(:active_record_postgresqladapter) do
|
|
@@ -108,7 +110,6 @@ module Switchman
|
|
|
108
110
|
end
|
|
109
111
|
end
|
|
110
112
|
|
|
111
|
-
::ActiveSupport.on_load(:active_record_fixtures) { prepend ActiveRecord::TestFixtures }
|
|
112
113
|
# Ensure that ActiveRecord::Base is always loaded before any app-level
|
|
113
114
|
# initializers can go try to load Switchman::Shard or we get a loop
|
|
114
115
|
::ActiveRecord::Base
|
data/lib/switchman/shard.rb
CHANGED
|
@@ -76,11 +76,7 @@ module Switchman
|
|
|
76
76
|
@default ||= default
|
|
77
77
|
|
|
78
78
|
# Now find the actual record, if it exists
|
|
79
|
-
@default =
|
|
80
|
-
find_cached("default_shard") { Shard.find_by(default: true) } || default
|
|
81
|
-
rescue
|
|
82
|
-
default
|
|
83
|
-
end
|
|
79
|
+
@default = find_default_shard(default)
|
|
84
80
|
|
|
85
81
|
# make sure this is not erroneously cached
|
|
86
82
|
if @default.database_server.instance_variable_defined?(:@primary_shard)
|
|
@@ -445,6 +441,21 @@ module Switchman
|
|
|
445
441
|
|
|
446
442
|
private
|
|
447
443
|
|
|
444
|
+
def find_default_shard(fallback)
|
|
445
|
+
return fallback unless Switchman.cache
|
|
446
|
+
|
|
447
|
+
find_cached("default_shard") { Shard.find_by(default: true) } || fallback
|
|
448
|
+
rescue ::ActiveRecord::NoDatabaseError,
|
|
449
|
+
::ActiveRecord::ConnectionNotEstablished,
|
|
450
|
+
::ActiveRecord::ConnectionFailed,
|
|
451
|
+
::PG::ConnectionBad
|
|
452
|
+
fallback
|
|
453
|
+
rescue ::ActiveRecord::StatementInvalid => e
|
|
454
|
+
raise unless e.cause.is_a?(::PG::UndefinedTable)
|
|
455
|
+
|
|
456
|
+
fallback
|
|
457
|
+
end
|
|
458
|
+
|
|
448
459
|
def add_sharded_model(klass)
|
|
449
460
|
@sharded_models = (sharded_models + [klass]).freeze
|
|
450
461
|
configure_connects_to
|
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.9
|
|
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-09-
|
|
13
|
+
date: 2026-09-15 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activerecord
|