taskinator 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1a746ba56e5b6a2f57736990eef9e83eafe8701fcbebaaddea258a010f3ee14
4
- data.tar.gz: 5e17bc8e6a61b93d6df0691dc463fb178aca72957ab79eccaea7b9cd6c1af642
3
+ metadata.gz: 553051326370b73612679e5e466e4dea25b8ae525c964038ef2300ebd146f869
4
+ data.tar.gz: 76e6febc439dbacfd81d15cbc691a582704ee1fae7dd414ace676e39b4fd4e63
5
5
  SHA512:
6
- metadata.gz: 8f8cd10cc4c8f5d45d5cc781b379927bae7c0ed5c280e2470450a818a6a3132af75bc11a4c16eef6312056f984e912f3fa758bd45e493988cee37fd01ad92d87
7
- data.tar.gz: f8b330d3f6e6766f6ddbc33becd3bb6d16826a021dd0ba16c3b2ec8308cdfe31caad40621fcbc542d6662c8aababaa946e369d251c82b24a213f955a942192a3
6
+ metadata.gz: 7216ab9db50025dc54c25cc00a4d2b696788173dcc2dbe4e8bbc4ccb9088e4c87373b9e6fa237a9ed7888c08af33c38da344ddfb2aa22f4fdc393995e4f22433
7
+ data.tar.gz: 8e268d20568348320f45fb9252fac13cfa7f7638745f196e49a721d0230fd677562aba760407e8d45e93ed410772323126fd596852959975d5c64079cde042db
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. iOS]
28
+ - Browser [e.g. chrome, safari]
29
+ - Version [e.g. 22]
30
+
31
+ **Smartphone (please complete the following information):**
32
+ - Device: [e.g. iPhone6]
33
+ - OS: [e.g. iOS8.1]
34
+ - Browser [e.g. stock browser, safari]
35
+ - Version [e.g. 22]
36
+
37
+ **Additional context**
38
+ Add any other context about the problem here.
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: Custom issue template
3
+ about: Describe this issue template's purpose here.
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,41 @@
1
+ name: Taskinator
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+
7
+ pull_request:
8
+ branches: [ master ]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version:
16
+ - '2.7'
17
+ - '3.0'
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true
25
+ - name: Build Gem
26
+ run: bundle exec rake build
27
+ - name: Run tests
28
+ run: bundle exec rake spec
29
+
30
+ publish:
31
+ if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
32
+ needs: build
33
+ runs-on: ubuntu-latest
34
+ steps:
35
+ - uses: actions/checkout@v2
36
+ - name: Release Gem
37
+ uses: discourse/publish-rubygems-action@v2
38
+ env:
39
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
40
+ GIT_NAME: Chris Stefano
41
+ GIT_EMAIL: virtualstaticvoid@gmail.com
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.7.2
1
+ ruby-3.0.0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ v0.4.4 - 17 Jan 2022
2
+ ---
3
+ Add support for `ActiveJob`.
4
+
1
5
  v0.4.3 - 14 Jan 2022
2
6
  ---
3
7
  Add `#find_process` and `#find_task` methods to `Taskinator::Api`.
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ virtualstaticvoid@gmail.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,58 @@
1
+ # How to contribute
2
+
3
+ All kinds of contributions are welcome. By participating you agree to follow the [code of conduct].
4
+
5
+ If you find an issue, have an idea for a new feature or any improvement, you can report them
6
+ as issues or submit pull requests. To maintain an organized process, please read the following
7
+ guidelines before submitting.
8
+
9
+ ## Reporting Issues
10
+
11
+ Before reporting new issues, please verify if there are any existing issues for the same problem
12
+ by searching in [issues].
13
+
14
+ Please make sure to give a clear name to the issue and describe it with all relevant information.
15
+ Giving examples can help understand your suggestion or, in case of issues to reproduce the problem.
16
+
17
+ ## Sending Pull Requests
18
+
19
+ Look at existing [issues] to see if there are any related issues that your feature/fix should
20
+ consider. If there are none, please create one describing your implementations intent. You should
21
+ always mention a related issue in the pull request description.
22
+
23
+ While writing code, follow the code conventions that you find in the existing code.
24
+
25
+ Try to write short, clear and objective commit messages too. You can squash your commits and
26
+ improve your commit messages once your done.
27
+
28
+ Also make sure to add good tests to your new code. Only refactoring of tested features and
29
+ documentation do not need new tests. This way your changes will be documented and future
30
+ changes will not break what you added.
31
+
32
+ ### Step-by-step
33
+
34
+ - Fork the repository.
35
+ - Commit and push until your are happy of what you have done.
36
+ - Execute the full test suite to ensure all is passing.
37
+ - Squash commits if necessary.
38
+ - Push to your repository.
39
+ - Open a pull request to the original repository.
40
+ - Give your pull request a good description. Do not forget to mention a related issue.
41
+
42
+ ## Running Tests
43
+
44
+ Once you cloned the gem to your development environment, you should run the following command
45
+ from the root folder to install the project dependencies.
46
+
47
+ ```bash
48
+ ./bin/setup
49
+ ```
50
+
51
+ After that, you can execute the tests suite by running the following command from the root folder.
52
+
53
+ ```bash
54
+ rake spec
55
+ ```
56
+
57
+ [code of conduct]: CODE_OF_CONDUCT.md
58
+ [issues]: https://github.com/virtualstaticvoid/taskinator/issues
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  # queues
7
+ gem 'activejob' , '>= 5.0.0'
7
8
  gem 'sidekiq' , '>= 3.5.0'
8
9
  gem 'rspec-sidekiq' , '>= 2.1.0'
9
10
 
@@ -16,7 +17,10 @@ gem 'resque_spec' , '>= 0.16.0'
16
17
  gem 'bundler' , '>= 1.6.0'
17
18
  gem 'rake' , '>= 10.3.0'
18
19
  gem 'activesupport' , '~> 5.2.0'
20
+
19
21
  gem 'rspec'
22
+ gem 'rspec-rails' , '>= 2.0'
23
+
20
24
  gem 'coveralls' , '>= 0.8.22'
21
25
  gem 'pry' , '>= 0.9.0'
22
26
  gem 'pry-byebug' , '>= 1.3.0'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- taskinator (0.4.3)
4
+ taskinator (0.4.4)
5
5
  builder (>= 3.2.2)
6
6
  connection_pool (>= 2.2.0)
7
7
  globalid (~> 0.3)
@@ -14,6 +14,22 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
+ actionpack (5.2.6)
18
+ actionview (= 5.2.6)
19
+ activesupport (= 5.2.6)
20
+ rack (~> 2.0, >= 2.0.8)
21
+ rack-test (>= 0.6.3)
22
+ rails-dom-testing (~> 2.0)
23
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
24
+ actionview (5.2.6)
25
+ activesupport (= 5.2.6)
26
+ builder (~> 3.1)
27
+ erubi (~> 1.4)
28
+ rails-dom-testing (~> 2.0)
29
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
30
+ activejob (5.2.6)
31
+ activesupport (= 5.2.6)
32
+ globalid (>= 0.3.6)
17
33
  activesupport (5.2.6)
18
34
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
35
  i18n (>= 0.7, < 2)
@@ -30,11 +46,13 @@ GEM
30
46
  term-ansicolor (~> 1.3)
31
47
  thor (>= 0.19.4, < 2.0)
32
48
  tins (~> 1.6)
49
+ crass (1.0.6)
33
50
  delayed_job (4.1.9)
34
51
  activesupport (>= 3.0, < 6.2)
35
52
  diff-lcs (1.5.0)
36
53
  docile (1.4.0)
37
54
  e2mmap (0.1.0)
55
+ erubi (1.10.0)
38
56
  fakeredis (0.7.0)
39
57
  redis (>= 3.2, < 5.0)
40
58
  globalid (0.6.0)
@@ -42,21 +60,42 @@ GEM
42
60
  i18n (1.8.11)
43
61
  concurrent-ruby (~> 1.0)
44
62
  json (2.6.1)
63
+ loofah (2.13.0)
64
+ crass (~> 1.0.2)
65
+ nokogiri (>= 1.5.9)
45
66
  method_source (1.0.0)
67
+ mini_portile2 (2.7.1)
46
68
  minitest (5.15.0)
47
69
  mono_logger (1.1.1)
48
70
  multi_json (1.15.0)
49
71
  mustermann (1.1.1)
50
72
  ruby2_keywords (~> 0.0.1)
51
- pry (0.14.1)
73
+ nokogiri (1.13.1)
74
+ mini_portile2 (~> 2.7.0)
75
+ racc (~> 1.4)
76
+ pry (0.13.1)
52
77
  coderay (~> 1.1)
53
78
  method_source (~> 1.0)
54
- pry-byebug (3.8.0)
79
+ pry-byebug (3.9.0)
55
80
  byebug (~> 11.0)
56
- pry (~> 0.10)
81
+ pry (~> 0.13.0)
82
+ racc (1.6.0)
57
83
  rack (2.2.3)
58
84
  rack-protection (2.1.0)
59
85
  rack
86
+ rack-test (1.1.0)
87
+ rack (>= 1.0, < 3)
88
+ rails-dom-testing (2.0.3)
89
+ activesupport (>= 4.2.0)
90
+ nokogiri (>= 1.6)
91
+ rails-html-sanitizer (1.4.2)
92
+ loofah (~> 2.3)
93
+ railties (5.2.6)
94
+ actionpack (= 5.2.6)
95
+ activesupport (= 5.2.6)
96
+ method_source
97
+ rake (>= 0.8.7)
98
+ thor (>= 0.19.0, < 2.0)
60
99
  rake (13.0.6)
61
100
  redis (4.5.1)
62
101
  redis-namespace (1.8.1)
@@ -78,12 +117,20 @@ GEM
78
117
  rspec-mocks (~> 3.10.0)
79
118
  rspec-core (3.10.1)
80
119
  rspec-support (~> 3.10.0)
81
- rspec-expectations (3.10.1)
120
+ rspec-expectations (3.10.2)
82
121
  diff-lcs (>= 1.2.0, < 2.0)
83
122
  rspec-support (~> 3.10.0)
84
123
  rspec-mocks (3.10.2)
85
124
  diff-lcs (>= 1.2.0, < 2.0)
86
125
  rspec-support (~> 3.10.0)
126
+ rspec-rails (5.0.2)
127
+ actionpack (>= 5.2)
128
+ activesupport (>= 5.2)
129
+ railties (>= 5.2)
130
+ rspec-core (~> 3.10)
131
+ rspec-expectations (~> 3.10)
132
+ rspec-mocks (~> 3.10)
133
+ rspec-support (~> 3.10)
87
134
  rspec-sidekiq (3.1.0)
88
135
  rspec-core (~> 3.0, >= 3.0.0)
89
136
  sidekiq (>= 2.4.0)
@@ -123,6 +170,7 @@ PLATFORMS
123
170
  ruby
124
171
 
125
172
  DEPENDENCIES
173
+ activejob (>= 5.0.0)
126
174
  activesupport (~> 5.2.0)
127
175
  bundler (>= 1.6.0)
128
176
  coveralls (>= 0.8.22)
@@ -134,9 +182,10 @@ DEPENDENCIES
134
182
  resque (>= 1.25.2)
135
183
  resque_spec (>= 0.16.0)
136
184
  rspec
185
+ rspec-rails (>= 2.0)
137
186
  rspec-sidekiq (>= 2.1.0)
138
187
  sidekiq (>= 3.5.0)
139
188
  taskinator!
140
189
 
141
190
  BUNDLED WITH
142
- 2.2.14
191
+ 2.3.5
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # Taskinator
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/taskinator.svg)](http://badge.fury.io/rb/taskinator)
4
- [![Build Status](https://secure.travis-ci.org/virtualstaticvoid/taskinator.png?branch=master)](http://travis-ci.org/virtualstaticvoid/taskinator)
4
+ [![Build Status](https://img.shields.io/github/workflow/status/virtualstaticvoid/taskinator/Taskinator?style=flat-square)](https://github.com/virtualstaticvoid/taskinator/actions)
5
5
  [![Code Climate](https://codeclimate.com/github/virtualstaticvoid/taskinator.png)](https://codeclimate.com/github/virtualstaticvoid/taskinator)
6
- [![Coverage Status](https://coveralls.io/repos/virtualstaticvoid/taskinator/badge.png)](https://coveralls.io/r/virtualstaticvoid/taskinator)
7
6
 
8
7
  A simple orchestration library for running complex processes or workflows in Ruby.
9
8
  Processes are defined using a simple DSL, where the sequences and tasks are defined.
@@ -13,6 +12,7 @@ and the overall process can be monitored for completion or failure.
13
12
  Processes and tasks are executed by background workers and you can use any one of the
14
13
  following gems:
15
14
 
15
+ * [active_job](https://github.com/rails/rails/tree/main/activejob)
16
16
  * [resque](https://github.com/resque/resque)
17
17
  * [sidekiq](https://github.com/mperham/sidekiq)
18
18
  * [delayed_job](https://github.com/collectiveidea/delayed_job)
@@ -22,8 +22,8 @@ Redis key/values.
22
22
 
23
23
  ## Requirements
24
24
 
25
- The latest MRI (2.1, 2.0) version. Other versions/VMs are untested but might work fine.
26
- MRI 1.9 is not supported.
25
+ The latest MRI 2.x or 3.x version. Other versions/VMs are untested, but might work fine.
26
+ MRI 1.x is not supported.
27
27
 
28
28
  Redis 2.4 or greater is required.
29
29
 
@@ -39,7 +39,7 @@ Add this line to your application's Gemfile:
39
39
 
40
40
  And then execute:
41
41
 
42
- $ bundle
42
+ $ bundle install
43
43
 
44
44
  Or install it yourself as:
45
45
 
@@ -53,6 +53,7 @@ Start by creating a "process" module and extending `Taskinator::Definition`.
53
53
 
54
54
  ```ruby
55
55
  require 'taskinator'
56
+
56
57
  module MyProcess
57
58
  extend Taskinator::Definition
58
59
 
@@ -148,15 +149,16 @@ module MyProcess
148
149
  end
149
150
  ```
150
151
 
151
- It is likely that you already have worker classes for one of the queueing libraries,
152
- such as resque or delayed_job, and wish to reuse them for executing them in the sequence
153
- defined by the process definition.
152
+ #### Reusing ActiveJob jobs
153
+
154
+ It is likely that you already have one or more [jobs](https://guides.rubyonrails.org/active_job_basics.html)
155
+ and want to reuse them within the process definition.
154
156
 
155
- Define a `job` step, providing the class of the worker, and then taskinator will execute
156
- that worker as part of the process definition.
157
+ Define a `job` step, providing the class of the Active Job to run and then taskinator will
158
+ invoke that job as part of the process.
157
159
 
158
- The `job` step will be queued and executed on same queue as configured by `delayed_job`, or
159
- that of the worker for `resque` and `sidekiq`.
160
+ The `job` step will be queued and executed on same queue as
161
+ [configured by the job](https://guides.rubyonrails.org/active_job_basics.html#queues).
160
162
 
161
163
  ```ruby
162
164
  # E.g. A resque worker
@@ -180,6 +182,8 @@ module MyProcess
180
182
  end
181
183
  ```
182
184
 
185
+ #### Data Driven Process Definitions
186
+
183
187
  You can also define data driven tasks using the `for_each` method, which takes an iterator method
184
188
  name as an argument.
185
189
 
@@ -207,6 +211,8 @@ module MyProcess
207
211
  end
208
212
  ```
209
213
 
214
+ #### Branching
215
+
210
216
  It is possible to branch the process logic based on the options hash passed in when creating
211
217
  a process. The `options?` method takes the options key as an argument and calls the supplied
212
218
  block if the option is present and it's value is _truthy_.
@@ -243,6 +249,8 @@ process2 = MyProcess.create_process
243
249
  process2.tasks.count #=> 1
244
250
  ```
245
251
 
252
+ #### Transformations
253
+
246
254
  In addition, it is possible to transform the arguments used by a task or job, by including
247
255
  a `transform` step in the definition.
248
256
 
@@ -271,6 +279,8 @@ module MyProcess
271
279
  end
272
280
  ```
273
281
 
282
+ #### Subprocesses
283
+
274
284
  Processes can be composed of other processes too:
275
285
 
276
286
  ```ruby
@@ -292,6 +302,8 @@ module MyProcess
292
302
  end
293
303
  ```
294
304
 
305
+ #### Complex Process Definitions
306
+
295
307
  Any combination or nesting of `task`, `sequential`, `concurrent` and `for_each` steps are
296
308
  possible. E.g.
297
309
 
@@ -0,0 +1,53 @@
1
+ module Taskinator
2
+ module Queues
3
+
4
+ # https://guides.rubyonrails.org/active_job_basics.html
5
+
6
+ def self.create_active_job_adapter(config={})
7
+ ActiveJobAdapter.new(config)
8
+ end
9
+
10
+ class ActiveJobAdapter
11
+ def initialize(config={})
12
+ @config = Taskinator::Queues::DefaultConfig.merge(config)
13
+ end
14
+
15
+ def enqueue_create_process(definition, uuid, args)
16
+ queue = definition.queue || @config[:definition_queue]
17
+ CreateProcessWorker.set(:queue => queue)
18
+ .perform_later(definition.name, uuid, Taskinator::Persistence.serialize(args))
19
+ end
20
+
21
+ def enqueue_process(process)
22
+ queue = process.queue || @config[:process_queue]
23
+ ProcessWorker.set(:queue => queue)
24
+ .perform_later(process.uuid)
25
+ end
26
+
27
+ def enqueue_task(task)
28
+ queue = task.queue || @config[:task_queue]
29
+ TaskWorker.set(:queue => queue)
30
+ .perform_later(task.uuid)
31
+ end
32
+
33
+ class CreateProcessWorker < ApplicationJob
34
+ def perform(definition_name, uuid, args)
35
+ Taskinator::CreateProcessWorker.new(definition_name, uuid, args).perform
36
+ end
37
+ end
38
+
39
+ class ProcessWorker < ApplicationJob
40
+ def perform(process_uuid)
41
+ Taskinator::ProcessWorker.new(process_uuid).perform
42
+ end
43
+ end
44
+
45
+ class TaskWorker < ApplicationJob
46
+ def perform(task_uuid)
47
+ Taskinator::TaskWorker.new(task_uuid).perform
48
+ end
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -48,6 +48,7 @@ module Taskinator
48
48
  end
49
49
  end
50
50
 
51
+ require 'taskinator/queues/active_job' if defined?(ApplicationJob)
51
52
  require 'taskinator/queues/delayed_job' if defined?(Delayed)
52
53
  require 'taskinator/queues/resque' if defined?(Resque)
53
54
  require 'taskinator/queues/sidekiq' if defined?(Sidekiq)
@@ -1,3 +1,3 @@
1
1
  module Taskinator
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
data/lib/taskinator.rb CHANGED
@@ -98,7 +98,7 @@ module Taskinator
98
98
 
99
99
  # the queue adapter to use
100
100
  # supported adapters include
101
- # :delayed_job, :redis and :sidekiq
101
+ # :active_job, :delayed_job, :redis and :sidekiq
102
102
  # NOTE: ensure that the respective gem is included
103
103
  attr_reader :queue_adapter
104
104
 
@@ -118,7 +118,7 @@ module Taskinator
118
118
 
119
119
  def queue
120
120
  @queue ||= begin
121
- adapter = self.queue_adapter || :resque
121
+ adapter = self.queue_adapter || :resque # TODO: change default to :active_job
122
122
  config = queue_config || {}
123
123
  Taskinator::Queues.create_adapter(adapter, config)
124
124
  end
data/spec/spec_helper.rb CHANGED
@@ -27,6 +27,20 @@ require 'resque'
27
27
  require 'resque_spec'
28
28
  ResqueSpec.disable_ext = false
29
29
 
30
+ require 'active_job'
31
+
32
+ ActiveJob::Base.queue_adapter = :test
33
+
34
+ class ApplicationJob < ActiveJob::Base
35
+ queue_as :not_used
36
+ end
37
+
38
+ # minimum rails gems for rspec/rails
39
+ require 'action_view'
40
+ require 'action_dispatch'
41
+ require 'action_controller'
42
+ require 'rspec/rails'
43
+
30
44
  require 'taskinator'
31
45
 
32
46
  Taskinator.configure do |config|
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+
3
+ describe Taskinator::Queues::ActiveJobAdapter, :active_job do
4
+
5
+ it_should_behave_like "a queue adapter", :active_job, Taskinator::Queues::ActiveJobAdapter
6
+
7
+ let(:adapter) { Taskinator::Queues::ActiveJobAdapter }
8
+ let(:uuid) { Taskinator.generate_uuid }
9
+
10
+ subject { adapter.new }
11
+
12
+ describe "CreateProcessWorker" do
13
+ let(:args) { Taskinator::Persistence.serialize(:foo => :bar) }
14
+
15
+ it "enqueues" do
16
+ worker = adapter::CreateProcessWorker
17
+ definition = MockDefinition.create
18
+ subject.enqueue_create_process(definition, uuid, :foo => :bar)
19
+
20
+ expect(worker).to have_been_enqueued.with(definition.name, uuid, args)
21
+ end
22
+
23
+ it "enqueues to specified queue" do
24
+ worker = adapter::CreateProcessWorker
25
+ definition = MockDefinition.create(:other)
26
+
27
+ subject.enqueue_create_process(definition, uuid, :foo => :bar)
28
+
29
+ expect(worker).to have_been_enqueued.with(definition.name, uuid, args).on_queue(:other)
30
+ end
31
+
32
+ it "calls worker" do
33
+ expect_any_instance_of(Taskinator::CreateProcessWorker).to receive(:perform)
34
+ adapter::CreateProcessWorker.new.perform(MockDefinition.create.name, uuid, args)
35
+ end
36
+ end
37
+
38
+ describe "ProcessWorker" do
39
+ it "enqueues processes" do
40
+ worker = adapter::ProcessWorker
41
+ subject.enqueue_process(double('process', :uuid => uuid, :queue => nil))
42
+
43
+ expect(worker).to have_been_enqueued.with(uuid)
44
+ end
45
+
46
+ it "enqueues process to specified queue" do
47
+ worker = adapter::ProcessWorker
48
+ subject.enqueue_process(double('process', :uuid => uuid, :queue => :other))
49
+
50
+ expect(worker).to have_been_enqueued.with(uuid).on_queue(:other)
51
+ end
52
+
53
+ it "calls process worker" do
54
+ expect_any_instance_of(Taskinator::ProcessWorker).to receive(:perform)
55
+ adapter::ProcessWorker.new.perform(uuid)
56
+ end
57
+ end
58
+
59
+ describe "TaskWorker" do
60
+ it "enqueues tasks" do
61
+ worker = adapter::TaskWorker
62
+ subject.enqueue_task(double('task', :uuid => uuid, :queue => nil))
63
+
64
+ expect(worker).to have_been_enqueued.with(uuid)
65
+ end
66
+
67
+ it "enqueues task to specified queue" do
68
+ worker = adapter::TaskWorker
69
+ subject.enqueue_task(double('task', :uuid => uuid, :queue => :other))
70
+
71
+ expect(worker).to have_been_enqueued.with(uuid).on_queue(:other)
72
+ end
73
+
74
+ it "calls task worker" do
75
+ expect_any_instance_of(Taskinator::TaskWorker).to receive(:perform)
76
+ adapter::TaskWorker.new.perform(uuid)
77
+ end
78
+ end
79
+
80
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taskinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Stefano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-14 00:00:00.000000000 Z
11
+ date: 2022-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -131,13 +131,17 @@ executables:
131
131
  extensions: []
132
132
  extra_rdoc_files: []
133
133
  files:
134
- - ".coveralls.yml"
134
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
135
+ - ".github/ISSUE_TEMPLATE/custom.md"
136
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
137
+ - ".github/workflows/taskinator.yml"
135
138
  - ".gitignore"
136
139
  - ".rspec"
137
140
  - ".ruby-gemset"
138
141
  - ".ruby-version"
139
- - ".travis.yml"
140
142
  - CHANGELOG.md
143
+ - CODE_OF_CONDUCT.md
144
+ - CONTRIBUTING.md
141
145
  - Gemfile
142
146
  - Gemfile.lock
143
147
  - LICENSE.txt
@@ -159,6 +163,7 @@ files:
159
163
  - lib/taskinator/process.rb
160
164
  - lib/taskinator/process_worker.rb
161
165
  - lib/taskinator/queues.rb
166
+ - lib/taskinator/queues/active_job.rb
162
167
  - lib/taskinator/queues/delayed_job.rb
163
168
  - lib/taskinator/queues/resque.rb
164
169
  - lib/taskinator/queues/sidekiq.rb
@@ -200,6 +205,7 @@ files:
200
205
  - spec/taskinator/persistence_spec.rb
201
206
  - spec/taskinator/process_spec.rb
202
207
  - spec/taskinator/process_worker_spec.rb
208
+ - spec/taskinator/queues/active_job_spec.rb
203
209
  - spec/taskinator/queues/delayed_job_spec.rb
204
210
  - spec/taskinator/queues/resque_spec.rb
205
211
  - spec/taskinator/queues/sidekiq_spec.rb
@@ -232,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
238
  - !ruby/object:Gem::Version
233
239
  version: '0'
234
240
  requirements: []
235
- rubygems_version: 3.2.3
241
+ rubygems_version: 3.1.6
236
242
  signing_key:
237
243
  specification_version: 4
238
244
  summary: A simple orchestration library for running complex processes or workflows
@@ -266,6 +272,7 @@ test_files:
266
272
  - spec/taskinator/persistence_spec.rb
267
273
  - spec/taskinator/process_spec.rb
268
274
  - spec/taskinator/process_worker_spec.rb
275
+ - spec/taskinator/queues/active_job_spec.rb
269
276
  - spec/taskinator/queues/delayed_job_spec.rb
270
277
  - spec/taskinator/queues/resque_spec.rb
271
278
  - spec/taskinator/queues/sidekiq_spec.rb
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: travis-ci
data/.travis.yml DELETED
@@ -1,23 +0,0 @@
1
- os: linux
2
- dist: xenial
3
- language: ruby
4
- cache: bundler
5
-
6
- services:
7
- - redis
8
-
9
- rvm:
10
- - 2.5.8
11
- - 2.6.6
12
- - 2.7.2
13
- - 3.0.0
14
-
15
- script: 'bundle exec rake spec'
16
-
17
- notifications:
18
- email:
19
- recipients:
20
- - virtualstaticvoid@gmail.com
21
- on_failure: change
22
- on_success: never
23
-