sidekiq_lifecycle_hooks 1.1.0 → 1.2.0
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/CHANGELOG.md +5 -0
- data/lib/lifecycle_job.rb +18 -5
- data/lib/sidekiq_lifecycle_hooks/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: c9f6952ed887b4100cf66995f956ba991321208c27dec44696b13f38ed228dbe
|
4
|
+
data.tar.gz: 67fcab6bfbf89f60d88cec414e3aa75c2f41ceda81f6146172523feb99d9393d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1d8103f922ba8c5c0503f5471a88b57b3782c3f7394f43b736adb57313a37db6134b6d9ba82e0bd637fdf2be484bef456f2f07b1c4908b13469697ef1601712
|
7
|
+
data.tar.gz: 0371e9a8adcc25640be69b44af53e88044074383ae49525e361f0a587f5bf32e85b16634b87a3e7d6cc0dbe90dfa6d3e7a20461c7840e3ad986ce4741e6efe0b
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
|
2
|
+
### 1.2.0
|
3
|
+
|
4
|
+
- Added a retry in Async job where record cannot be found, in case
|
5
|
+
attempt to find record occurred too early. This can happen when the initial record creation is delayed by e.g. after_create hooks and indexes.
|
6
|
+
|
2
7
|
### 1.1.0
|
3
8
|
|
4
9
|
- Add early return in Async Job for when record cannot be found
|
data/lib/lifecycle_job.rb
CHANGED
@@ -3,11 +3,14 @@ class LifecycleJob
|
|
3
3
|
sidekiq_options queue: :default, retry: 1
|
4
4
|
|
5
5
|
def perform(class_name, record_id, action, previous_attrs = '{}')
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
|
7
|
+
record = fetch_record(class_name, record_id, action, previous_attrs)
|
8
|
+
unless record
|
9
|
+
sleep 3 # waits for 3 seconds before retrying
|
10
|
+
record = fetch_record(class_name, record_id, action, previous_attrs)
|
11
|
+
end
|
12
|
+
|
13
|
+
return unless record
|
11
14
|
|
12
15
|
case action
|
13
16
|
when 'create'
|
@@ -18,4 +21,14 @@ class LifecycleJob
|
|
18
21
|
record.async_after_destroy_actions
|
19
22
|
end
|
20
23
|
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def fetch_record(class_name, record_id, action, previous_attrs)
|
28
|
+
if action == 'destroy'
|
29
|
+
class_name.constantize.new(JSON.parse(previous_attrs))
|
30
|
+
else
|
31
|
+
class_name.constantize.find_by(id: record_id)
|
32
|
+
end
|
33
|
+
end
|
21
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq_lifecycle_hooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10
|
11
|
+
date: 2023-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|