sidekiq_workflows 0.2.3 → 1.0.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sidekiq_workflows/worker.rb +20 -5
  3. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a72a673bff2b06b52efa9b4c1850b00e60dda029cbd014bb5c18c97de341743c
4
- data.tar.gz: d0c51fde3f914762c31636e98a025e90719b8f3c107e6671846829c7394dbafb
3
+ metadata.gz: cfe14b006b243a658de47101698b0b0b47e73b881275745f17a13851cec71efc
4
+ data.tar.gz: 6b66f424a92e434152ffce19079435de9ec12884cc24cbf16e623d8571948082
5
5
  SHA512:
6
- metadata.gz: da3206c3422a4ae213fc2fd2bfb07221378d029e15c3fb35a6260bf749798f318ebdbf7fb6023317281990728e7148819070c0f3cd33c6d2664873de54af35df
7
- data.tar.gz: 8e4a7fd1f097a20d63ac9668ad2153d39b17201f3bca7e09e1eec0711ad5b691daf78e5428817fccc4e75e4dc47b4162abed22c0ed1ded3690bdc53ddd95a6e1
6
+ metadata.gz: c87521b82948cd1a084612c06556361d69e7a4739094aa1ba3b3cc65d1d79016773c0f39e10b7de8f17909d9b683a55871b594720a54aeb43e23daf417fdbe55
7
+ data.tar.gz: ffb5ef5cf0bd7f3bf23664d819ab4cd5b80040c009ad1fc3965611a890bdddd31fcbcd4dde19c00d8e633f8ff8077f58c584bcb95fa72c8d92c59a9eb612c139
@@ -17,7 +17,8 @@ module SidekiqWorkflows
17
17
  child_batch = Sidekiq::Batch.new
18
18
  child_batch.callback_queue = SidekiqWorkflows.callback_queue unless SidekiqWorkflows.callback_queue.nil?
19
19
  child_batch.description = "Workflow #{workflow.workflow_uuid || '-'}"
20
- child_batch.on(:complete, 'SidekiqWorkflows::Worker#on_complete', workflow: workflow.serialize, workflow_uuid: workflow.workflow_uuid)
20
+ child_batch.on(:success, 'SidekiqWorkflows::Worker#on_success', workflow: workflow.serialize, workflow_uuid: workflow.workflow_uuid)
21
+ child_batch.on(:death, 'SidekiqWorkflows::Worker#on_death', workflow: workflow.serialize, workflow_uuid: workflow.workflow_uuid)
21
22
  child_batch.jobs do
22
23
  workflow.workers.each do |entry|
23
24
  if entry[:delay]
@@ -31,7 +32,7 @@ module SidekiqWorkflows
31
32
  end
32
33
  end
33
34
 
34
- def on_complete(status, options)
35
+ def on_success(status, options)
35
36
  workflow = ensure_deserialized(options['workflow'])
36
37
 
37
38
  if workflow.on_partial_complete
@@ -39,21 +40,35 @@ module SidekiqWorkflows
39
40
  ActiveSupport::Inflector.constantize(klass).new.send(method, status, options)
40
41
  end
41
42
 
42
- perform_children(status.parent_batch, workflow) unless status.failures > 0
43
+ perform_children(status.parent_batch, workflow)
44
+ end
45
+
46
+ def on_death(status, options)
47
+ workflow = ensure_deserialized(options['workflow'])
48
+
49
+ if workflow.on_partial_complete
50
+ klass, method = workflow.on_partial_complete.split('#')
51
+ ActiveSupport::Inflector.constantize(klass).new.send(method, status, options)
52
+ end
43
53
  end
44
54
 
45
55
  def self.perform_async(workflow, *args)
46
56
  set(queue: worker_queue).send(:perform_async, workflow.serialize, *args)
47
57
  end
48
58
 
49
- def self.perform_workflow(workflow, on_complete: nil, on_complete_options: {})
59
+ def self.perform_workflow(workflow, on_success: nil, on_success_options: {}, on_death: nil, on_death_options: {})
50
60
  batch = Sidekiq::Batch.new
51
61
  batch.callback_queue = SidekiqWorkflows.callback_queue unless SidekiqWorkflows.callback_queue.nil?
52
62
  batch.description = "Workflow #{workflow.workflow_uuid || '-'} root batch"
53
- batch.on(:complete, on_complete, on_complete_options.merge(workflow_uuid: workflow.workflow_uuid)) if on_complete
63
+ batch.on(:success, on_success, on_success_options.merge(workflow_uuid: workflow.workflow_uuid)) if on_success
64
+ batch.on(:death, on_death, on_death_options.merge(workflow_uuid: workflow.workflow_uuid)) if on_death
65
+
66
+ yield batch if block_given?
67
+
54
68
  batch.jobs do
55
69
  perform_async(workflow)
56
70
  end
71
+
57
72
  batch.bid
58
73
  end
59
74
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq_workflows
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marian Theisen
8
8
  - Christian Semmler
9
9
  - Patrick Detlefsen
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-08-16 00:00:00.000000000 Z
13
+ date: 2021-09-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sidekiq-pro
@@ -18,26 +18,26 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '3.0'
21
+ version: 5.2.1
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '3.0'
28
+ version: 5.2.1
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: activesupport
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - "~>"
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
35
  version: '4.0'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - "~>"
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: '4.0'
43
43
  - !ruby/object:Gem::Dependency
@@ -116,7 +116,7 @@ homepage: https://github.com/easymarketing/sidekiq_workflows
116
116
  licenses:
117
117
  - MIT
118
118
  metadata: {}
119
- post_install_message:
119
+ post_install_message:
120
120
  rdoc_options: []
121
121
  require_paths:
122
122
  - lib
@@ -131,8 +131,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubygems_version: 3.0.3
135
- signing_key:
134
+ rubygems_version: 3.1.6
135
+ signing_key:
136
136
  specification_version: 4
137
137
  summary: Sidekiq extension providing a workflow API on top of Sidekiq Pro's batches
138
138
  test_files: []