switchman 3.4.0 → 3.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/switchman/active_record/base.rb +12 -1
- data/lib/switchman/errors.rb +8 -4
- 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: 28d87755bf2331cbbf2931e7d35dddd688983c168c583b27dd60ae58d78072db
|
4
|
+
data.tar.gz: 500e141f914db02c5dd51cd9a595abc00306750a418641ceb09adb7cee207de7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94c9b870a65599c0d5775d32cd9dd1bfc3235c541eeb07127e5e8e8c773447da3ba1e0460ce8a340709354aceede546b9d6ccf8dd0360bff7e494f267a6791e1
|
7
|
+
data.tar.gz: 6ea8348a8aaa9eb80ae763d2c8ccca23949e329f0f9ae2df7eef59344fdf3d4660b6e7419f479bc5d67be5e42fdd73f49abf7f0ceb853c0469c38b0899559424
|
@@ -171,11 +171,22 @@ module Switchman
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
+
def destroy_shadow_records(target_shards: [Shard.current])
|
175
|
+
raise Errors::ShadowRecordError, 'Cannot be called on a shadow record.' if shadow_record?
|
176
|
+
raise Errors::MethodUnsupportedForUnshardedTableError, 'Cannot be called on a record belonging to an unsharded table.' unless self.class.sharded_column?(self.class.primary_key)
|
177
|
+
|
178
|
+
Array(target_shards).each do |target_shard|
|
179
|
+
next if target_shard == shard
|
180
|
+
|
181
|
+
target_shard.activate { self.class.where('id = ?', global_id).delete_all }
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
174
185
|
# Returns "the shard that this record was actually loaded from" , as
|
175
186
|
# opposed to "the shard this record belongs on", which might be
|
176
187
|
# different if this is a shadow record.
|
177
188
|
def loaded_from_shard
|
178
|
-
@loaded_from_shard ||
|
189
|
+
@loaded_from_shard || shard
|
179
190
|
end
|
180
191
|
|
181
192
|
def shard
|
data/lib/switchman/errors.rb
CHANGED
@@ -2,14 +2,18 @@
|
|
2
2
|
|
3
3
|
module Switchman
|
4
4
|
module Errors
|
5
|
-
class NonExistentShardError < RuntimeError; end
|
6
|
-
|
7
|
-
class ParallelShardExecError < RuntimeError; end
|
8
|
-
|
9
5
|
class ManuallyCreatedShadowRecordError < RuntimeError
|
10
6
|
def initialize(msg = "It looks like you're trying to manually create a shadow record. Please use Switchman::ActiveRecord::Base#save_shadow_record instead.")
|
11
7
|
super
|
12
8
|
end
|
13
9
|
end
|
10
|
+
|
11
|
+
class NonExistentShardError < RuntimeError; end
|
12
|
+
|
13
|
+
class ParallelShardExecError < RuntimeError; end
|
14
|
+
|
15
|
+
class ShadowRecordError < RuntimeError; end
|
16
|
+
|
17
|
+
class UnshardedTableError < RuntimeError; end
|
14
18
|
end
|
15
19
|
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: 3.4.
|
4
|
+
version: 3.4.2
|
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: 2023-
|
13
|
+
date: 2023-04-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|