taskinator 0.4.0 → 0.4.4
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/ISSUE_TEMPLATE/bug_report.md +38 -0
- data/.github/ISSUE_TEMPLATE/custom.md +10 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/workflows/taskinator.yml +41 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +19 -0
- data/CODE_OF_CONDUCT.md +128 -0
- data/CONTRIBUTING.md +58 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +71 -22
- data/README.md +184 -71
- data/lib/taskinator/api.rb +14 -5
- data/lib/taskinator/definition/builder.rb +16 -7
- data/lib/taskinator/persistence.rb +3 -0
- data/lib/taskinator/queues/active_job.rb +53 -0
- data/lib/taskinator/queues.rb +1 -0
- data/lib/taskinator/version.rb +1 -1
- data/lib/taskinator.rb +2 -2
- data/spec/spec_helper.rb +14 -0
- data/spec/support/test_flows.rb +38 -0
- data/spec/taskinator/api_spec.rb +16 -0
- data/spec/taskinator/definition/builder_spec.rb +48 -0
- data/spec/taskinator/persistence_spec.rb +21 -17
- data/spec/taskinator/queues/active_job_spec.rb +80 -0
- data/spec/taskinator/task_spec.rb +1 -1
- metadata +12 -5
- data/.coveralls.yml +0 -1
- data/.travis.yml +0 -23
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|
|
data/spec/support/test_flows.rb
CHANGED
@@ -132,4 +132,42 @@ module TestFlows
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
module NestedTask
|
136
|
+
extend Taskinator::Definition
|
137
|
+
include Support
|
138
|
+
|
139
|
+
define_process :task_count do
|
140
|
+
task :task_1
|
141
|
+
|
142
|
+
concurrent do
|
143
|
+
task :task_2
|
144
|
+
task :task_3
|
145
|
+
|
146
|
+
sequential do
|
147
|
+
task :task_4
|
148
|
+
task :task_5
|
149
|
+
|
150
|
+
concurrent do
|
151
|
+
task :task_6
|
152
|
+
task :task_7
|
153
|
+
|
154
|
+
sequential do
|
155
|
+
task :task_8
|
156
|
+
task :task_9
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
task :task_10
|
161
|
+
end
|
162
|
+
|
163
|
+
task :task_11
|
164
|
+
end
|
165
|
+
|
166
|
+
task :task_12
|
167
|
+
end
|
168
|
+
|
169
|
+
task :task_13
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
135
173
|
end
|
data/spec/taskinator/api_spec.rb
CHANGED
@@ -44,4 +44,20 @@ describe Taskinator::Api, :redis => true do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
describe "#find_process" do
|
48
|
+
it {
|
49
|
+
# fetch method is covered by persistence spec
|
50
|
+
expect(Taskinator::Process).to receive(:fetch) {}
|
51
|
+
subject.find_process 'foo:bar:process'
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#find_task" do
|
56
|
+
it {
|
57
|
+
# fetch method is covered by persistence spec
|
58
|
+
expect(Taskinator::Task).to receive(:fetch) {}
|
59
|
+
subject.find_task 'foo:bar:process:baz:task'
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
47
63
|
end
|
@@ -75,6 +75,22 @@ describe Taskinator::Definition::Builder do
|
|
75
75
|
expect(Taskinator::Process).to receive(:define_sequential_process_for).with(definition, options).and_call_original
|
76
76
|
subject.sequential(options, &define_block)
|
77
77
|
end
|
78
|
+
|
79
|
+
it "adds sub-process task" do
|
80
|
+
block = Proc.new {|p|
|
81
|
+
p.task :task_method
|
82
|
+
}
|
83
|
+
expect(process.tasks).to be_empty
|
84
|
+
subject.sequential(options, &block)
|
85
|
+
expect(process.tasks).to_not be_empty
|
86
|
+
end
|
87
|
+
|
88
|
+
it "ignores sub-processes without tasks" do
|
89
|
+
allow(block).to receive(:call)
|
90
|
+
expect(process.tasks).to be_empty
|
91
|
+
subject.sequential(options, &define_block)
|
92
|
+
expect(process.tasks).to be_empty
|
93
|
+
end
|
78
94
|
end
|
79
95
|
|
80
96
|
describe "#concurrent" do
|
@@ -100,6 +116,22 @@ describe Taskinator::Definition::Builder do
|
|
100
116
|
expect(Taskinator::Process).to receive(:define_concurrent_process_for).with(definition, Taskinator::CompleteOn::First, options).and_call_original
|
101
117
|
subject.concurrent(Taskinator::CompleteOn::First, options, &define_block)
|
102
118
|
end
|
119
|
+
|
120
|
+
it "adds sub-process task" do
|
121
|
+
block = Proc.new {|p|
|
122
|
+
p.task :task_method
|
123
|
+
}
|
124
|
+
expect(process.tasks).to be_empty
|
125
|
+
subject.sequential(options, &block)
|
126
|
+
expect(process.tasks).to_not be_empty
|
127
|
+
end
|
128
|
+
|
129
|
+
it "ignores sub-processes without tasks" do
|
130
|
+
allow(block).to receive(:call)
|
131
|
+
expect(process.tasks).to be_empty
|
132
|
+
subject.sequential(options, &define_block)
|
133
|
+
expect(process.tasks).to be_empty
|
134
|
+
end
|
103
135
|
end
|
104
136
|
|
105
137
|
describe "#for_each" do
|
@@ -235,6 +267,22 @@ describe Taskinator::Definition::Builder do
|
|
235
267
|
expect(sub_definition).to receive(:create_sub_process).with(*args, builder_options.merge(options)).and_call_original
|
236
268
|
subject.sub_process(sub_definition, options)
|
237
269
|
end
|
270
|
+
|
271
|
+
it "adds sub-process task" do
|
272
|
+
block = Proc.new {|p|
|
273
|
+
p.task :task_method
|
274
|
+
}
|
275
|
+
expect(process.tasks).to be_empty
|
276
|
+
subject.sequential(options, &block)
|
277
|
+
expect(process.tasks).to_not be_empty
|
278
|
+
end
|
279
|
+
|
280
|
+
it "ignores sub-processes without tasks" do
|
281
|
+
allow(block).to receive(:call)
|
282
|
+
expect(process.tasks).to be_empty
|
283
|
+
subject.sequential(options, &define_block)
|
284
|
+
expect(process.tasks).to be_empty
|
285
|
+
end
|
238
286
|
end
|
239
287
|
|
240
288
|
end
|
@@ -370,24 +370,27 @@ describe Taskinator::Persistence, :redis => true do
|
|
370
370
|
TestFlows::Job,
|
371
371
|
TestFlows::SubProcess,
|
372
372
|
TestFlows::Sequential,
|
373
|
-
TestFlows::Concurrent
|
373
|
+
TestFlows::Concurrent,
|
374
|
+
TestFlows::EmptySequentialProcessTest,
|
375
|
+
TestFlows::EmptyConcurrentProcessTest,
|
376
|
+
TestFlows::NestedTask,
|
374
377
|
].each do |definition|
|
375
378
|
|
376
379
|
describe "#{definition.name} expire immediately" do
|
377
380
|
it {
|
378
|
-
process = definition.create_process(1)
|
379
|
-
|
380
381
|
Taskinator.redis do |conn|
|
381
|
-
|
382
|
+
# sanity check
|
383
|
+
expect(conn.keys).to be_empty
|
382
384
|
|
383
|
-
process.
|
385
|
+
process = definition.create_process(1)
|
384
386
|
|
385
|
-
|
387
|
+
# sanity check
|
388
|
+
expect(conn.hget(process.key, :uuid)).to eq(process.uuid)
|
386
389
|
|
387
|
-
|
388
|
-
expect(conn.hget(task.key, :uuid)).to be_nil
|
389
|
-
end
|
390
|
+
process.cleanup(0) # immediately
|
390
391
|
|
392
|
+
# ensure nothing left behind
|
393
|
+
expect(conn.keys).to be_empty
|
391
394
|
end
|
392
395
|
}
|
393
396
|
end
|
@@ -396,9 +399,14 @@ describe Taskinator::Persistence, :redis => true do
|
|
396
399
|
|
397
400
|
describe "expires in future" do
|
398
401
|
it {
|
399
|
-
process = TestFlows::Task.create_process(1)
|
400
|
-
|
401
402
|
Taskinator.redis do |conn|
|
403
|
+
|
404
|
+
# sanity check
|
405
|
+
expect(conn.keys).to be_empty
|
406
|
+
|
407
|
+
process = TestFlows::Task.create_process(1)
|
408
|
+
|
409
|
+
# sanity check
|
402
410
|
expect(conn.hget(process.key, :uuid)).to eq(process.uuid)
|
403
411
|
|
404
412
|
process.cleanup(2)
|
@@ -411,12 +419,8 @@ describe Taskinator::Persistence, :redis => true do
|
|
411
419
|
|
412
420
|
sleep 3
|
413
421
|
|
414
|
-
#
|
415
|
-
expect(conn.
|
416
|
-
recursively_enumerate_tasks(process.tasks) do |task|
|
417
|
-
expect(conn.hget(task.key, :uuid)).to be_nil
|
418
|
-
end
|
419
|
-
|
422
|
+
# ensure nothing left behind
|
423
|
+
expect(conn.keys).to be_empty
|
420
424
|
end
|
421
425
|
}
|
422
426
|
end
|
@@ -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
|
@@ -227,7 +227,7 @@ describe Taskinator::Task do
|
|
227
227
|
|
228
228
|
method = subject.method
|
229
229
|
|
230
|
-
executor.class_eval do
|
230
|
+
executor.singleton_class.class_eval do
|
231
231
|
define_method method do |*args|
|
232
232
|
# this method executes in the scope of the executor
|
233
233
|
# store the context in an instance variable
|
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.
|
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:
|
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
|
-
- ".
|
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.1.
|
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
|
-
|