sidekiq-sequence 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/app/models/sidekiq/sequence/record.rb +2 -0
- data/lib/generators/sidekiq_sequence/install_generator.rb +11 -0
- data/lib/generators/sidekiq_sequence/templates/migration.rb.tt +1 -1
- data/lib/sidekiq/sequence/base.rb +8 -3
- data/lib/sidekiq/sequence/perform.rb +4 -1
- data/lib/sidekiq/sequence/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: 9651141aaf29a94360df739c7a16272b19b3ced0b6cf25ff56ea897b021952af
|
4
|
+
data.tar.gz: badd2b56cb8be4a5bbfb147851c73f10c0bae36939f0dcc1fc2f5538dd68dde5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b40ba6749f55b6f28003e85a242a157ab709947159444795302dd51d4e3b5547c94befd5c6e0e20ea88a582f314440b33f8394fa76fee09ce33ea519884fa0c2
|
7
|
+
data.tar.gz: a316aafe5e4688dc9307ebd19896e59a0f3a3a9efc73fcbbf66d3572935cc13250c2d654f813ec74e2e05cf9e3b303092e06a1b79b51b0d4ba3bfaccd823b52c
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# Sidekiq::Sequence - Sequential Sidekiq jobs.
|
2
2
|
|
3
|
-
Sidekiq is awesome, but it doesn't provide any support for sequential jobs, where a sequence of jobs must be run in a set order.
|
3
|
+
Sidekiq is awesome, but it doesn't provide any support for sequential jobs, where a sequence of jobs must be run in a set order.
|
4
4
|
|
5
|
-
Sidekiq::Sequence
|
5
|
+
Sidekiq::Sequence provides a simple yet powerful framework to run a sequence of Sidekiq jobs, where each job runs only when the previous job successfully completes. It relies on Sidekiq's retry functionality to handle failed jobs. So if a job fails, any subsequent jobs will not run. Once the job is retried and is successful, the next job will start.
|
6
|
+
|
7
|
+
> **NOTE:** Sidekiq::Sequence is currently only intended for use in Rails applications.
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -19,6 +19,17 @@ module SidekiqSequence
|
|
19
19
|
def migration_version
|
20
20
|
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
21
21
|
end
|
22
|
+
|
23
|
+
def properties_type
|
24
|
+
case ActiveRecord::Base.connection_config[:adapter].to_s
|
25
|
+
when /postg/i # postgres, postgis
|
26
|
+
'jsonb'
|
27
|
+
when /mysql/i
|
28
|
+
'json'
|
29
|
+
else
|
30
|
+
'text'
|
31
|
+
end
|
32
|
+
end
|
22
33
|
end
|
23
34
|
end
|
24
35
|
end
|
@@ -7,7 +7,12 @@ module Sidekiq
|
|
7
7
|
@@steps = []
|
8
8
|
|
9
9
|
def self.step(worker_class)
|
10
|
-
|
10
|
+
klass = worker_class.name
|
11
|
+
@@steps << klass unless @@steps.include?(klass)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.steps
|
15
|
+
@@steps
|
11
16
|
end
|
12
17
|
|
13
18
|
def self.perform_step(index, id)
|
@@ -15,7 +20,7 @@ module Sidekiq
|
|
15
20
|
# No more steps in the sequence, so delete the record.
|
16
21
|
Record.destroy id
|
17
22
|
else
|
18
|
-
@@steps[index].perform_async id
|
23
|
+
@@steps[index].constantize.perform_async id
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
@@ -23,7 +28,7 @@ module Sidekiq
|
|
23
28
|
record = Record.create(data: data)
|
24
29
|
|
25
30
|
# Start first job in the sequence.
|
26
|
-
@@steps.first.perform_async record.id
|
31
|
+
@@steps.first.constantize.perform_async record.id
|
27
32
|
end
|
28
33
|
end
|
29
34
|
# rubocop:enable Style/ClassVars
|
@@ -9,7 +9,10 @@ module Sidekiq
|
|
9
9
|
|
10
10
|
super(*args)
|
11
11
|
|
12
|
-
|
12
|
+
# Increment the step and update data attribute.
|
13
|
+
@record.increment(:current_step)
|
14
|
+
@record.data = @data
|
15
|
+
@record.save!
|
13
16
|
|
14
17
|
# Perform the next in sequence.
|
15
18
|
self.class.parent.perform_step @record.current_step, @record.id
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-sequence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Moss
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Create and manage sequential jobs in Sidekiq
|
14
14
|
email:
|