sidekiq-activerecord-shard 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8381904a8af934466f4f06293c2c5bbf76fa72f2d23071f475b6930f12a8a25
|
4
|
+
data.tar.gz: a9541f4e5f55f1273d74ca1a860174b36c826baebc3f872dba3e96ae33b28efc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a4a9fe58e64c0bb7acbdf789896f5c41e463567eb3f4070201dcb0d1d479491838a40515f5249ff9e5c80e3e0b3c68ce1ab5f0ecfa2e87252702f0a93b7e3dc
|
7
|
+
data.tar.gz: 0a6a28a40e51c6f1d031d762d93e3026ddd36c5717a5c84e66225828d2678fff701546bac4478278f9116453ba78ae57ac1d806a18422bb1f3d2a090fdd0520e
|
@@ -6,7 +6,12 @@ module SidekiqActiveRecordShard
|
|
6
6
|
|
7
7
|
def call(_jobclass, job, _queue, _redis)
|
8
8
|
# Store shard value in Job arguments
|
9
|
-
|
9
|
+
shard = SidekiqActiveRecordShard.config.selected_shard.call
|
10
|
+
if shard.nil?
|
11
|
+
raise "No shard selected, SidekiqActiveRecordShard.config.selected_shard return nil."
|
12
|
+
end
|
13
|
+
|
14
|
+
job["_active_record_shard"] = shard
|
10
15
|
yield
|
11
16
|
end
|
12
17
|
end
|
@@ -19,7 +24,7 @@ module SidekiqActiveRecordShard
|
|
19
24
|
|
20
25
|
# Inspired by ActiveRecord::Middleware::ShardSelector
|
21
26
|
# https://github.com/rails/rails/blob/v7.0.3/activerecord/lib/active_record/middleware/shard_selector.rb#L54
|
22
|
-
def set_shard(
|
27
|
+
def set_shard(shard, &block)
|
23
28
|
options = Rails.application.config.active_record.shard_selector
|
24
29
|
|
25
30
|
ActiveRecord::Base.connected_to(shard: shard.to_sym) do
|