dwf 0.1.5 → 0.1.6
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/.github/workflows/build_gem.yaml +4 -0
- data/.github/workflows/test.yaml +1 -1
- data/CHANGELOG.md +41 -0
- data/README.md +5 -4
- data/dwf.gemspec +1 -1
- data/lib/dwf/callback.rb +38 -9
- data/lib/dwf.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a08560cdfefa1c9f8e1f42416599e94550de0f0e1492bb5b05424e2bf94a482f
|
|
4
|
+
data.tar.gz: 84a83b6849b64e7fe5da74f5734e2d8faa96df25eef63a5d0de78229fcc733ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6eb847d86872dfa70c1a602a3ae8ef0e0ca166cfa22d0a5e3706454ef0144ac434b48489a916d811e9dc66ebb9ef4979b00b63dee8da4d08c44af6d1bd714dad
|
|
7
|
+
data.tar.gz: cda011bc87919531f5de78721c3640c2460119cb4dd5668bd4ebb8093e19d46e848d27cfc2112c10021bd41e52e2365ced092f779a25a1509086fdf7095221a9
|
data/.github/workflows/test.yaml
CHANGED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
## 0.1.6
|
|
4
|
+
### Added
|
|
5
|
+
- Sidekiq batch callback: separate batches
|
|
6
|
+
|
|
7
|
+
## 0.1.5
|
|
8
|
+
### Added
|
|
9
|
+
- add github action with build and public gem flow
|
|
10
|
+
|
|
11
|
+
## 0.1.4
|
|
12
|
+
### Added
|
|
13
|
+
- Add testes
|
|
14
|
+
- add github action
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Remove Sidekiq pro by default
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
## 0.1.3
|
|
21
|
+
### Added
|
|
22
|
+
- Support both build in and [Sidekiq batches](https://github.com/mperham/sidekiq/wiki/Batches) callback
|
|
23
|
+
- Update readme
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
- Fix bug require development gem
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
## 0.1.2
|
|
30
|
+
### Added
|
|
31
|
+
- Support [Sidekiq batches](https://github.com/mperham/sidekiq/wiki/Batches) callback
|
|
32
|
+
- Update readme
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
- fix typo and remove development gem
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
## 0.1.0
|
|
39
|
+
### Added
|
|
40
|
+
- init app with basic idea following [Gush](https://github.com/chaps-io/gush) concept
|
|
41
|
+
- Support build in callback
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Installation
|
|
5
5
|
## 1. Add `dwf` to Gemfile
|
|
6
6
|
```ruby
|
|
7
|
-
gem 'dwf', '~> 0.1.
|
|
7
|
+
gem 'dwf', '~> 0.1.5'
|
|
8
8
|
```
|
|
9
9
|
## 2. Execute flow
|
|
10
10
|
### Declare jobs
|
|
@@ -39,7 +39,7 @@ end
|
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
#### Note
|
|
42
|
-
`dwf` supports 2
|
|
42
|
+
`dwf` supports 2 callback types `Dwf::Workflow::BUILD_IN` and `Dwf::Workflow::SK_BATCH`
|
|
43
43
|
- `Dwf::Workflow::BUILD_IN` is a build-in callback
|
|
44
44
|
- `Dwf::Workflow::SK_BATCH` is [sidekiq batch](https://github.com/mperham/sidekiq/wiki/Batches) callback which required [`sidekiq-pro`](https://sidekiq.org/products/pro.html)
|
|
45
45
|
|
|
@@ -47,7 +47,7 @@ By default `dwf` will use `Dwf::Workflow::BUILD_IN` callback.
|
|
|
47
47
|
|
|
48
48
|
### Execute flow
|
|
49
49
|
```ruby
|
|
50
|
-
wf = TestWf.create
|
|
50
|
+
wf = TestWf.create(callback_type: Dwf::Workflow::SK_BATCH)
|
|
51
51
|
wf.start!
|
|
52
52
|
```
|
|
53
53
|
|
|
@@ -75,8 +75,9 @@ D Finished
|
|
|
75
75
|
- [x] Support pass params
|
|
76
76
|
- [x] Support with build-in callback
|
|
77
77
|
- [x] Add github workflow
|
|
78
|
-
- [ ] [
|
|
78
|
+
- [ ] [WIP] Test
|
|
79
79
|
- [ ] Transfer output through each node
|
|
80
|
+
- [ ] Support [Resque](https://github.com/resque/resque)
|
|
80
81
|
|
|
81
82
|
# References
|
|
82
83
|
- https://github.com/chaps-io/gush
|
data/dwf.gemspec
CHANGED
data/lib/dwf/callback.rb
CHANGED
|
@@ -22,19 +22,48 @@ module Dwf
|
|
|
22
22
|
private
|
|
23
23
|
|
|
24
24
|
def setup_batch(processing_job_names, workflow_id)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
jobs = fetch_jobs(processing_job_names, workflow_id)
|
|
26
|
+
jobs_classification = classify_jobs jobs
|
|
27
|
+
|
|
28
|
+
jobs_classification.values.each do |batch_jobs|
|
|
29
|
+
batch = Sidekiq::Batch.new
|
|
30
|
+
batch.on(
|
|
31
|
+
:success,
|
|
32
|
+
'Dwf::Callback#process_next_step',
|
|
33
|
+
names: batch_jobs.map(&:klass),
|
|
34
|
+
workflow_id: workflow_id
|
|
35
|
+
)
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
batch.jobs do
|
|
38
|
+
batch_jobs.each do |job|
|
|
39
|
+
job.persist_and_perform_async! if job.ready_to_start?
|
|
40
|
+
end
|
|
41
|
+
end
|
|
35
42
|
end
|
|
36
43
|
end
|
|
37
44
|
|
|
45
|
+
def classify_jobs(jobs)
|
|
46
|
+
hash = {}
|
|
47
|
+
jobs.each do |job|
|
|
48
|
+
outgoing_jobs = job.outgoing
|
|
49
|
+
key = outgoing_jobs.empty? ? 'default_key' : outgoing_jobs.join
|
|
50
|
+
|
|
51
|
+
if hash[key].nil?
|
|
52
|
+
hash[key] = [job]
|
|
53
|
+
else
|
|
54
|
+
hash[key] = hash[key].push(job)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
hash
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def fetch_jobs(processing_job_names, workflow_id)
|
|
62
|
+
processing_job_names.map do |job_name|
|
|
63
|
+
client.find_job(workflow_id, job_name)
|
|
64
|
+
end.compact
|
|
65
|
+
end
|
|
66
|
+
|
|
38
67
|
def perform_job(job_name, workflow_id)
|
|
39
68
|
with_lock workflow_id, job_name do
|
|
40
69
|
job = client.find_job(workflow_id, job_name)
|
data/lib/dwf.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dwf
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- dthtien
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-09-
|
|
11
|
+
date: 2021-09-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: byebug
|
|
@@ -78,6 +78,7 @@ files:
|
|
|
78
78
|
- ".gitignore"
|
|
79
79
|
- ".rspec"
|
|
80
80
|
- ".ruby-version"
|
|
81
|
+
- CHANGELOG.md
|
|
81
82
|
- Gemfile
|
|
82
83
|
- LICENSE.txt
|
|
83
84
|
- README.md
|