switchman 3.4.0 → 3.4.1
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/active_record/base.rb +11 -0
- 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: e080637567925bab42e7d6c87a2963486b16fb5a09eab87ef61fd8056d773ddf
|
4
|
+
data.tar.gz: 2694d7353b3cb7df6976aa812897540f1a9fc2188c5a6d2cc15bebfbbabb1371
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3318e8323ebda712ad41873279793ddd5b0d5849a536c9f2dc0fcd3addefb35ff4d364882f27eb59d0c8e27e7c5d79e5c5edc6de66a73024746f79fed23170f
|
7
|
+
data.tar.gz: a2d2a1b1682febaffe2856dbdee8eca77241d5781e60fe037677f39c5c77b30d4d4ec5d6b0ff5e8c6cdd947fa79171fc99f0b19ffc3a5a77185bb400069ab537
|
@@ -171,6 +171,17 @@ 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.
|
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.1
|
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-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|