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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cfd1989fd7228daec1f81759e249cb3a0d6e920e465b38f1f6998239c78f6c7
4
- data.tar.gz: 0e4139ec4372ef7f5fb91b61cae9b2131e7e5b5983e25219a213b3edb821c9c6
3
+ metadata.gz: a08560cdfefa1c9f8e1f42416599e94550de0f0e1492bb5b05424e2bf94a482f
4
+ data.tar.gz: 84a83b6849b64e7fe5da74f5734e2d8faa96df25eef63a5d0de78229fcc733ba
5
5
  SHA512:
6
- metadata.gz: 38b96a776878ddce8df1757ecdba3452a833f117536b9a3f44a07dc801ce71be7ac7cfac997622cd3e172c1a2929ac333f50e4823f901cb844149189c18563de
7
- data.tar.gz: 3a32f7469c5a7009e8f04a1d1c9e35fcd8de4fb322593f8e3c9f90fa617fe96eda8dc768dd97c5a3f7bb9044a2eaa87632970fcdddfd6bb57e96c6d72446951b
6
+ metadata.gz: 6eb847d86872dfa70c1a602a3ae8ef0e0ca166cfa22d0a5e3706454ef0144ac434b48489a916d811e9dc66ebb9ef4979b00b63dee8da4d08c44af6d1bd714dad
7
+ data.tar.gz: cda011bc87919531f5de78721c3640c2460119cb4dd5668bd4ebb8093e19d46e848d27cfc2112c10021bd41e52e2365ced092f779a25a1509086fdf7095221a9
@@ -6,8 +6,12 @@ on:
6
6
  # Alternatively, publish whenever changes are merged to the `main` branch.
7
7
  push:
8
8
  branches: [ master ]
9
+ paths:
10
+ - 'dwf.gemspec'
9
11
  pull_request:
10
12
  branches: [ master ]
13
+ paths:
14
+ - 'dwf.gemspec'
11
15
 
12
16
  jobs:
13
17
  build:
@@ -1,4 +1,4 @@
1
- name: dwf
1
+ name: Test
2
2
 
3
3
  on:
4
4
  push:
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.3'
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 type of callback `Dwf::Workflow::BUILD_IN` and `Dwf::Workflow::SK_BATCH`
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
- - [ ] [WIF] Test
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
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = "dwf"
9
- spec.version = '0.1.5'
9
+ spec.version = '0.1.6'
10
10
  spec.authors = ["dthtien"]
11
11
  spec.email = ["tiendt2311@gmail.com"]
12
12
 
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
- batch = Sidekiq::Batch.new
26
- batch.on(
27
- :success,
28
- 'Dwf::Callback#process_next_step',
29
- names: processing_job_names,
30
- workflow_id: workflow_id
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
- batch.jobs do
34
- processing_job_names.each { |job_name| perform_job(job_name, workflow_id) }
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
@@ -14,6 +14,6 @@ require_relative 'dwf/worker'
14
14
  require_relative 'dwf/callback'
15
15
 
16
16
  module Dwf
17
- VERSION = '0.1.3'
17
+ VERSION = '0.1.6'
18
18
  end
19
19
 
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.5
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-05 00:00:00.000000000 Z
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