taskinator 0.3.11 → 0.3.16
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 +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +4 -5
- data/Gemfile +3 -3
- data/Gemfile.lock +89 -82
- data/README.md +0 -1
- data/lib/taskinator.rb +1 -0
- data/lib/taskinator/process.rb +6 -3
- data/lib/taskinator/version.rb +1 -1
- data/spec/examples/queue_adapter_examples.rb +4 -4
- data/spec/spec_helper.rb +1 -4
- data/spec/taskinator/process_spec.rb +151 -1
- data/spec/taskinator/queues/sidekiq_spec.rb +3 -3
- data/taskinator.gemspec +3 -1
- metadata +19 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 231c6c9f1bdcf8bb1a7fb38c0ebd0c893f61f49051d94ace5714233a207ad651
|
|
4
|
+
data.tar.gz: 9c66bf91f8420f3fff69487e095a5c36986409f7249224f03ba0b53fdd427190
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0e322ccc3214ed171bd75b14b4ebaa7e51c1e1ba33b3f7f292c707059f166566a8b8c08235442d26922b0cd8a8c2affa320af03d069d33b0fce4d9ffe7485e95
|
|
7
|
+
data.tar.gz: d16a3220d1be357c77e7a47d3e2c426a99549c3d350979f534a176ec3919444551956d4d41e6b7389e245fe39c1286d7ef60e6f07b1155f3aeae7e9cdce1398b
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ruby-2.
|
|
1
|
+
ruby-2.7.2
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -15,10 +15,10 @@ gem 'resque_spec' , '>= 0.16.0'
|
|
|
15
15
|
# other
|
|
16
16
|
gem 'bundler' , '>= 1.6.0'
|
|
17
17
|
gem 'rake' , '>= 10.3.0'
|
|
18
|
-
gem 'activesupport' , '~>
|
|
18
|
+
gem 'activesupport' , '~> 5.2.0'
|
|
19
19
|
gem 'rspec'
|
|
20
|
-
gem 'coveralls' , '>= 0.
|
|
20
|
+
gem 'coveralls' , '>= 0.8.22'
|
|
21
21
|
gem 'pry' , '>= 0.9.0'
|
|
22
22
|
gem 'pry-byebug' , '>= 1.3.0'
|
|
23
23
|
|
|
24
|
-
gem 'fakeredis' , '~> 0.
|
|
24
|
+
gem 'fakeredis' , '~> 0.7.0'
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
taskinator (0.3.
|
|
4
|
+
taskinator (0.3.16)
|
|
5
5
|
builder (>= 3.2.2)
|
|
6
6
|
connection_pool (>= 2.2.0)
|
|
7
7
|
globalid (~> 0.3)
|
|
@@ -9,108 +9,115 @@ PATH
|
|
|
9
9
|
redis (>= 3.2.1)
|
|
10
10
|
redis-namespace (>= 1.5.2)
|
|
11
11
|
redis-semaphore (>= 0.2.4)
|
|
12
|
-
statsd-ruby (~> 1.
|
|
12
|
+
statsd-ruby (~> 1.4.0)
|
|
13
|
+
thwait (~> 0.2)
|
|
13
14
|
|
|
14
15
|
GEM
|
|
15
16
|
remote: https://rubygems.org/
|
|
16
17
|
specs:
|
|
17
|
-
activesupport (
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
activesupport (5.2.4.5)
|
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
20
|
+
i18n (>= 0.7, < 2)
|
|
20
21
|
minitest (~> 5.1)
|
|
21
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
|
22
22
|
tzinfo (~> 1.1)
|
|
23
|
-
builder (3.2.
|
|
24
|
-
byebug (
|
|
25
|
-
coderay (1.1.
|
|
26
|
-
concurrent-ruby (1.
|
|
27
|
-
connection_pool (2.2.
|
|
28
|
-
coveralls (0.8.
|
|
23
|
+
builder (3.2.4)
|
|
24
|
+
byebug (11.1.3)
|
|
25
|
+
coderay (1.1.3)
|
|
26
|
+
concurrent-ruby (1.1.8)
|
|
27
|
+
connection_pool (2.2.3)
|
|
28
|
+
coveralls (0.8.23)
|
|
29
29
|
json (>= 1.8, < 3)
|
|
30
|
-
simplecov (~> 0.
|
|
30
|
+
simplecov (~> 0.16.1)
|
|
31
31
|
term-ansicolor (~> 1.3)
|
|
32
|
-
thor (
|
|
33
|
-
tins (
|
|
34
|
-
delayed_job (4.1.
|
|
35
|
-
activesupport (>= 3.0, <
|
|
36
|
-
diff-lcs (1.
|
|
37
|
-
docile (1.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
thor (>= 0.19.4, < 2.0)
|
|
33
|
+
tins (~> 1.6)
|
|
34
|
+
delayed_job (4.1.9)
|
|
35
|
+
activesupport (>= 3.0, < 6.2)
|
|
36
|
+
diff-lcs (1.4.4)
|
|
37
|
+
docile (1.3.5)
|
|
38
|
+
e2mmap (0.1.0)
|
|
39
|
+
fakeredis (0.7.0)
|
|
40
|
+
redis (>= 3.2, < 5.0)
|
|
41
|
+
globalid (0.4.2)
|
|
42
|
+
activesupport (>= 4.2.0)
|
|
43
|
+
i18n (1.8.9)
|
|
44
|
+
concurrent-ruby (~> 1.0)
|
|
45
|
+
json (2.5.1)
|
|
46
|
+
method_source (1.0.0)
|
|
47
|
+
minitest (5.14.3)
|
|
46
48
|
mono_logger (1.1.0)
|
|
47
|
-
multi_json (1.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
rack
|
|
49
|
+
multi_json (1.15.0)
|
|
50
|
+
mustermann (1.1.1)
|
|
51
|
+
ruby2_keywords (~> 0.0.1)
|
|
52
|
+
pry (0.13.1)
|
|
53
|
+
coderay (~> 1.1)
|
|
54
|
+
method_source (~> 1.0)
|
|
55
|
+
pry-byebug (3.9.0)
|
|
56
|
+
byebug (~> 11.0)
|
|
57
|
+
pry (~> 0.13.0)
|
|
58
|
+
rack (2.2.3)
|
|
59
|
+
rack-protection (2.1.0)
|
|
57
60
|
rack
|
|
58
|
-
rake (
|
|
59
|
-
redis (
|
|
60
|
-
redis-namespace (1.
|
|
61
|
-
redis (
|
|
61
|
+
rake (13.0.3)
|
|
62
|
+
redis (4.2.5)
|
|
63
|
+
redis-namespace (1.8.1)
|
|
64
|
+
redis (>= 3.0.4)
|
|
62
65
|
redis-semaphore (0.3.1)
|
|
63
66
|
redis
|
|
64
|
-
resque (
|
|
67
|
+
resque (2.0.0)
|
|
65
68
|
mono_logger (~> 1.0)
|
|
66
69
|
multi_json (~> 1.0)
|
|
67
|
-
redis-namespace (~> 1.
|
|
70
|
+
redis-namespace (~> 1.6)
|
|
68
71
|
sinatra (>= 0.9.2)
|
|
69
72
|
vegas (~> 0.1.2)
|
|
70
|
-
resque_spec (0.
|
|
71
|
-
resque (>= 1.
|
|
73
|
+
resque_spec (0.18.1)
|
|
74
|
+
resque (>= 1.26.0)
|
|
72
75
|
rspec-core (>= 3.0.0)
|
|
73
76
|
rspec-expectations (>= 3.0.0)
|
|
74
77
|
rspec-mocks (>= 3.0.0)
|
|
75
|
-
rspec (3.
|
|
76
|
-
rspec-core (~> 3.
|
|
77
|
-
rspec-expectations (~> 3.
|
|
78
|
-
rspec-mocks (~> 3.
|
|
79
|
-
rspec-core (3.
|
|
80
|
-
rspec-support (~> 3.
|
|
81
|
-
rspec-expectations (3.
|
|
78
|
+
rspec (3.10.0)
|
|
79
|
+
rspec-core (~> 3.10.0)
|
|
80
|
+
rspec-expectations (~> 3.10.0)
|
|
81
|
+
rspec-mocks (~> 3.10.0)
|
|
82
|
+
rspec-core (3.10.1)
|
|
83
|
+
rspec-support (~> 3.10.0)
|
|
84
|
+
rspec-expectations (3.10.1)
|
|
82
85
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
83
|
-
rspec-support (~> 3.
|
|
84
|
-
rspec-mocks (3.
|
|
86
|
+
rspec-support (~> 3.10.0)
|
|
87
|
+
rspec-mocks (3.10.2)
|
|
85
88
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
86
|
-
rspec-support (~> 3.
|
|
87
|
-
rspec-sidekiq (
|
|
88
|
-
rspec (~> 3.0, >= 3.0.0)
|
|
89
|
+
rspec-support (~> 3.10.0)
|
|
90
|
+
rspec-sidekiq (3.1.0)
|
|
91
|
+
rspec-core (~> 3.0, >= 3.0.0)
|
|
89
92
|
sidekiq (>= 2.4.0)
|
|
90
|
-
rspec-support (3.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
connection_pool (
|
|
94
|
-
rack
|
|
95
|
-
redis (
|
|
96
|
-
simplecov (0.
|
|
97
|
-
docile (~> 1.1
|
|
93
|
+
rspec-support (3.10.2)
|
|
94
|
+
ruby2_keywords (0.0.4)
|
|
95
|
+
sidekiq (6.1.3)
|
|
96
|
+
connection_pool (>= 2.2.2)
|
|
97
|
+
rack (~> 2.0)
|
|
98
|
+
redis (>= 4.2.0)
|
|
99
|
+
simplecov (0.16.1)
|
|
100
|
+
docile (~> 1.1)
|
|
98
101
|
json (>= 1.8, < 3)
|
|
99
102
|
simplecov-html (~> 0.10.0)
|
|
100
|
-
simplecov-html (0.10.
|
|
101
|
-
sinatra (1.
|
|
102
|
-
|
|
103
|
-
rack
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
statsd-ruby (1.
|
|
107
|
-
|
|
103
|
+
simplecov-html (0.10.2)
|
|
104
|
+
sinatra (2.1.0)
|
|
105
|
+
mustermann (~> 1.0)
|
|
106
|
+
rack (~> 2.2)
|
|
107
|
+
rack-protection (= 2.1.0)
|
|
108
|
+
tilt (~> 2.0)
|
|
109
|
+
statsd-ruby (1.4.0)
|
|
110
|
+
sync (0.5.0)
|
|
111
|
+
term-ansicolor (1.7.1)
|
|
108
112
|
tins (~> 1.0)
|
|
109
|
-
thor (
|
|
110
|
-
thread_safe (0.3.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
thor (1.1.0)
|
|
114
|
+
thread_safe (0.3.6)
|
|
115
|
+
thwait (0.2.0)
|
|
116
|
+
e2mmap
|
|
117
|
+
tilt (2.0.10)
|
|
118
|
+
tins (1.28.0)
|
|
119
|
+
sync
|
|
120
|
+
tzinfo (1.2.9)
|
|
114
121
|
thread_safe (~> 0.1)
|
|
115
122
|
vegas (0.1.11)
|
|
116
123
|
rack (>= 1.0.0)
|
|
@@ -119,11 +126,11 @@ PLATFORMS
|
|
|
119
126
|
ruby
|
|
120
127
|
|
|
121
128
|
DEPENDENCIES
|
|
122
|
-
activesupport (~>
|
|
129
|
+
activesupport (~> 5.2.0)
|
|
123
130
|
bundler (>= 1.6.0)
|
|
124
|
-
coveralls (>= 0.
|
|
131
|
+
coveralls (>= 0.8.22)
|
|
125
132
|
delayed_job (~> 4.1.0)
|
|
126
|
-
fakeredis (~> 0.
|
|
133
|
+
fakeredis (~> 0.7.0)
|
|
127
134
|
pry (>= 0.9.0)
|
|
128
135
|
pry-byebug (>= 1.3.0)
|
|
129
136
|
rake (>= 10.3.0)
|
|
@@ -135,4 +142,4 @@ DEPENDENCIES
|
|
|
135
142
|
taskinator!
|
|
136
143
|
|
|
137
144
|
BUNDLED WITH
|
|
138
|
-
|
|
145
|
+
2.2.11
|
data/README.md
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
[](http://travis-ci.org/virtualstaticvoid/taskinator)
|
|
5
5
|
[](https://codeclimate.com/github/virtualstaticvoid/taskinator)
|
|
6
6
|
[](https://coveralls.io/r/virtualstaticvoid/taskinator)
|
|
7
|
-
[](https://gemnasium.com/virtualstaticvoid/taskinator)
|
|
8
7
|
|
|
9
8
|
A simple orchestration library for running complex processes or workflows in Ruby. Processes are defined using a simple DSL, where the sequences and
|
|
10
9
|
tasks are defined. Processes can then be queued for execution. Sequences can be synchronous or asynchronous, and the overall process can be monitored
|
data/lib/taskinator.rb
CHANGED
data/lib/taskinator/process.rb
CHANGED
|
@@ -199,6 +199,12 @@ module Taskinator
|
|
|
199
199
|
end
|
|
200
200
|
|
|
201
201
|
def task_completed(task)
|
|
202
|
+
# deincrement the count of pending sequential tasks
|
|
203
|
+
pending = deincr_pending_tasks
|
|
204
|
+
|
|
205
|
+
Taskinator.statsd_client.count("taskinator.#{definition.name.underscore.parameterize}.pending", pending)
|
|
206
|
+
Taskinator.logger.info("Completed task for process '#{uuid}'. Pending is #{pending}.")
|
|
207
|
+
|
|
202
208
|
next_task = task.next
|
|
203
209
|
if next_task
|
|
204
210
|
next_task.enqueue!
|
|
@@ -258,9 +264,6 @@ module Taskinator
|
|
|
258
264
|
end
|
|
259
265
|
|
|
260
266
|
def task_completed(task)
|
|
261
|
-
# skip if failed
|
|
262
|
-
return if failed?
|
|
263
|
-
|
|
264
267
|
# deincrement the count of pending concurrent tasks
|
|
265
268
|
pending = deincr_pending_tasks
|
|
266
269
|
|
data/lib/taskinator/version.rb
CHANGED
|
@@ -14,9 +14,9 @@ shared_examples_for "a queue adapter" do |adapter_name, adapter_type|
|
|
|
14
14
|
it { expect(subject).to respond_to(:enqueue_create_process) }
|
|
15
15
|
|
|
16
16
|
it "should enqueue a create process" do
|
|
17
|
-
expect
|
|
17
|
+
expect(
|
|
18
18
|
subject.enqueue_create_process(double('definition', :name => 'definition', :queue => nil), 'xx-xx-xx-xx', :foo => :bar)
|
|
19
|
-
|
|
19
|
+
).to_not be_nil
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
@@ -24,9 +24,9 @@ shared_examples_for "a queue adapter" do |adapter_name, adapter_type|
|
|
|
24
24
|
it { expect(subject).to respond_to(:enqueue_task) }
|
|
25
25
|
|
|
26
26
|
it "should enqueue a task" do
|
|
27
|
-
expect
|
|
27
|
+
expect(
|
|
28
28
|
subject.enqueue_task(double('task', :uuid => 'xx-xx-xx-xx', :queue => nil))
|
|
29
|
-
|
|
29
|
+
).to_not be_nil
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -60,10 +60,7 @@ RSpec.configure do |config|
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
config.before(:each, :redis => true) do
|
|
63
|
-
Taskinator.redis = { :namespace =>
|
|
64
|
-
Taskinator.redis do |conn|
|
|
65
|
-
conn.flushdb
|
|
66
|
-
end
|
|
63
|
+
Taskinator.redis = { :namespace => "taskinator:test:#{SecureRandom.uuid}" }
|
|
67
64
|
end
|
|
68
65
|
|
|
69
66
|
config.before(:each, :sidekiq => true) do
|
|
@@ -288,6 +288,23 @@ describe Taskinator::Process do
|
|
|
288
288
|
subject.task_completed(task1)
|
|
289
289
|
end
|
|
290
290
|
|
|
291
|
+
it "deincrements the pending task count" do
|
|
292
|
+
tasks.each {|t| subject.tasks << t }
|
|
293
|
+
task1 = tasks[0]
|
|
294
|
+
task2 = tasks[1]
|
|
295
|
+
|
|
296
|
+
allow(task2).to receive(:enqueue!)
|
|
297
|
+
|
|
298
|
+
pending_count = tasks.count
|
|
299
|
+
allow(subject).to receive(:deincr_pending_tasks) { pending_count -= 1 }
|
|
300
|
+
|
|
301
|
+
subject.task_completed(task1)
|
|
302
|
+
expect(pending_count).to eq(tasks.count - 1)
|
|
303
|
+
|
|
304
|
+
subject.task_completed(task2)
|
|
305
|
+
expect(pending_count).to eq(tasks.count - 2)
|
|
306
|
+
end
|
|
307
|
+
|
|
291
308
|
it "completes if no more tasks" do
|
|
292
309
|
tasks.each {|t| subject.tasks << t }
|
|
293
310
|
task2 = tasks[1]
|
|
@@ -296,6 +313,30 @@ describe Taskinator::Process do
|
|
|
296
313
|
|
|
297
314
|
subject.task_completed(task2)
|
|
298
315
|
end
|
|
316
|
+
|
|
317
|
+
it "completes if failed task gets retried" do
|
|
318
|
+
tasks.each {|t| subject.tasks << t }
|
|
319
|
+
task1 = tasks[0]
|
|
320
|
+
task2 = tasks[1]
|
|
321
|
+
|
|
322
|
+
allow(task2).to receive(:enqueue!)
|
|
323
|
+
|
|
324
|
+
expect(subject).to receive(:fail!).and_call_original
|
|
325
|
+
expect(subject).to receive(:complete!).and_call_original
|
|
326
|
+
|
|
327
|
+
subject.task_completed(task1)
|
|
328
|
+
expect(subject.completed?).to_not be
|
|
329
|
+
expect(subject.failed?).to_not be
|
|
330
|
+
|
|
331
|
+
subject.task_failed(task2, StandardError.new)
|
|
332
|
+
expect(subject.completed?).to_not be
|
|
333
|
+
expect(subject.failed?).to be
|
|
334
|
+
|
|
335
|
+
# "retry" the task
|
|
336
|
+
subject.task_completed(task2)
|
|
337
|
+
expect(subject.completed?).to be
|
|
338
|
+
expect(subject.failed?).to_not be
|
|
339
|
+
end
|
|
299
340
|
end
|
|
300
341
|
|
|
301
342
|
describe "#tasks_completed?" do
|
|
@@ -315,6 +356,28 @@ describe Taskinator::Process do
|
|
|
315
356
|
end
|
|
316
357
|
end
|
|
317
358
|
|
|
359
|
+
describe "#task_failed" do
|
|
360
|
+
it "fails when tasks fail" do
|
|
361
|
+
tasks.each {|t| subject.tasks << t }
|
|
362
|
+
|
|
363
|
+
error = StandardError.new
|
|
364
|
+
|
|
365
|
+
expect(subject).to receive(:fail!).with(error)
|
|
366
|
+
|
|
367
|
+
subject.task_failed(tasks.first, error)
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
it "doesn't deincement pending task count" do
|
|
371
|
+
tasks.each {|t| subject.tasks << t }
|
|
372
|
+
|
|
373
|
+
expect(subject).to_not receive(:deincr_pending_tasks)
|
|
374
|
+
|
|
375
|
+
error = StandardError.new
|
|
376
|
+
|
|
377
|
+
subject.task_failed(tasks.first, error)
|
|
378
|
+
end
|
|
379
|
+
end
|
|
380
|
+
|
|
318
381
|
describe "#accept" do
|
|
319
382
|
it { expect(subject).to be_a(Taskinator::Persistence) }
|
|
320
383
|
|
|
@@ -422,7 +485,8 @@ describe Taskinator::Process do
|
|
|
422
485
|
process = Taskinator::Process.define_concurrent_process_for(definition, Taskinator::CompleteOn::First)
|
|
423
486
|
tasks.each {|t| process.tasks << t }
|
|
424
487
|
|
|
425
|
-
|
|
488
|
+
pending_count = tasks.count
|
|
489
|
+
allow(process).to receive(:deincr_pending_tasks) { pending_count -= 1 }
|
|
426
490
|
|
|
427
491
|
expect(process).to receive(:complete!).once.and_call_original
|
|
428
492
|
|
|
@@ -450,6 +514,82 @@ describe Taskinator::Process do
|
|
|
450
514
|
expect(process.completed?).to be(false) unless pending_count < 1
|
|
451
515
|
end
|
|
452
516
|
end
|
|
517
|
+
|
|
518
|
+
it "deincrements the pending task count" do
|
|
519
|
+
tasks.each {|t| subject.tasks << t }
|
|
520
|
+
task1 = tasks[0]
|
|
521
|
+
task2 = tasks[1]
|
|
522
|
+
|
|
523
|
+
pending_count = tasks.count
|
|
524
|
+
allow(subject).to receive(:deincr_pending_tasks) { pending_count -= 1 }
|
|
525
|
+
|
|
526
|
+
subject.task_completed(task1)
|
|
527
|
+
expect(pending_count).to eq(tasks.count - 1)
|
|
528
|
+
|
|
529
|
+
subject.task_completed(task2)
|
|
530
|
+
expect(pending_count).to eq(tasks.count - 2)
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
describe "completes if failed task gets retried" do
|
|
534
|
+
it "after first task succeeds" do
|
|
535
|
+
tasks.each {|t| subject.tasks << t }
|
|
536
|
+
task1 = tasks[0]
|
|
537
|
+
task2 = tasks[1]
|
|
538
|
+
|
|
539
|
+
pending_count = tasks.count
|
|
540
|
+
allow(subject).to receive(:deincr_pending_tasks) { pending_count -= 1 }
|
|
541
|
+
allow(task2).to receive(:enqueue!)
|
|
542
|
+
|
|
543
|
+
expect(subject).to receive(:fail!).and_call_original
|
|
544
|
+
expect(subject).to receive(:complete!).and_call_original
|
|
545
|
+
|
|
546
|
+
# first task succeeds
|
|
547
|
+
subject.task_completed(task1)
|
|
548
|
+
expect(pending_count).to eq(tasks.count - 1)
|
|
549
|
+
|
|
550
|
+
# second task fails
|
|
551
|
+
subject.task_failed(task2, StandardError.new)
|
|
552
|
+
|
|
553
|
+
expect(subject.failed?).to be
|
|
554
|
+
expect(pending_count).to eq(tasks.count - 1)
|
|
555
|
+
|
|
556
|
+
# "retry" the task
|
|
557
|
+
subject.task_completed(task2)
|
|
558
|
+
|
|
559
|
+
expect(pending_count).to eq(tasks.count - 2)
|
|
560
|
+
expect(subject.failed?).to_not be
|
|
561
|
+
expect(subject.completed?).to be
|
|
562
|
+
end
|
|
563
|
+
|
|
564
|
+
it "after first task fails" do
|
|
565
|
+
tasks.each {|t| subject.tasks << t }
|
|
566
|
+
task1 = tasks[0]
|
|
567
|
+
task2 = tasks[1]
|
|
568
|
+
|
|
569
|
+
pending_count = tasks.count
|
|
570
|
+
allow(subject).to receive(:deincr_pending_tasks) { pending_count -= 1 }
|
|
571
|
+
allow(task2).to receive(:enqueue!)
|
|
572
|
+
|
|
573
|
+
expect(subject).to receive(:fail!).and_call_original
|
|
574
|
+
expect(subject).to receive(:complete!).and_call_original
|
|
575
|
+
|
|
576
|
+
# first task fails
|
|
577
|
+
subject.task_failed(task2, StandardError.new)
|
|
578
|
+
expect(subject.failed?).to be
|
|
579
|
+
expect(pending_count).to eq(tasks.count)
|
|
580
|
+
|
|
581
|
+
# second task succeeds
|
|
582
|
+
subject.task_completed(task1)
|
|
583
|
+
expect(pending_count).to eq(tasks.count - 1)
|
|
584
|
+
|
|
585
|
+
# "retry" the task
|
|
586
|
+
subject.task_completed(task2)
|
|
587
|
+
|
|
588
|
+
expect(pending_count).to eq(tasks.count - 2)
|
|
589
|
+
expect(subject.failed?).to_not be
|
|
590
|
+
expect(subject.completed?).to be
|
|
591
|
+
end
|
|
592
|
+
end
|
|
453
593
|
end
|
|
454
594
|
|
|
455
595
|
describe "#task_failed" do
|
|
@@ -462,6 +602,16 @@ describe Taskinator::Process do
|
|
|
462
602
|
|
|
463
603
|
subject.task_failed(tasks.first, error)
|
|
464
604
|
end
|
|
605
|
+
|
|
606
|
+
it "doesn't deincement pending task count" do
|
|
607
|
+
tasks.each {|t| subject.tasks << t }
|
|
608
|
+
|
|
609
|
+
expect(subject).to_not receive(:deincr_pending_tasks)
|
|
610
|
+
|
|
611
|
+
error = StandardError.new
|
|
612
|
+
|
|
613
|
+
subject.task_failed(tasks.first, error)
|
|
614
|
+
end
|
|
465
615
|
end
|
|
466
616
|
|
|
467
617
|
describe "#tasks_completed?" do
|
|
@@ -18,7 +18,7 @@ describe Taskinator::Queues::SidekiqAdapter, :sidekiq do
|
|
|
18
18
|
worker = adapter::CreateProcessWorker
|
|
19
19
|
definition = MockDefinition.create
|
|
20
20
|
subject.enqueue_create_process(definition, uuid, :foo => :bar)
|
|
21
|
-
expect(worker).to
|
|
21
|
+
expect(worker).to have_enqueued_sidekiq_job(definition.name, uuid, args)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it "enqueues to specified queue" do
|
|
@@ -38,7 +38,7 @@ describe Taskinator::Queues::SidekiqAdapter, :sidekiq do
|
|
|
38
38
|
worker = adapter::ProcessWorker
|
|
39
39
|
process = double('process', :uuid => uuid, :queue => nil)
|
|
40
40
|
subject.enqueue_process(process)
|
|
41
|
-
expect(worker).to
|
|
41
|
+
expect(worker).to have_enqueued_sidekiq_job(process.uuid)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "enqueues process to specified queue" do
|
|
@@ -57,7 +57,7 @@ describe Taskinator::Queues::SidekiqAdapter, :sidekiq do
|
|
|
57
57
|
worker = adapter::TaskWorker
|
|
58
58
|
task = double('task', :uuid => uuid, :queue => nil)
|
|
59
59
|
subject.enqueue_task(task)
|
|
60
|
-
expect(worker).to
|
|
60
|
+
expect(worker).to have_enqueued_sidekiq_job(task.uuid)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it "enqueues task to specified queue" do
|
data/taskinator.gemspec
CHANGED
|
@@ -28,5 +28,7 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
spec.add_dependency 'json' , '>= 1.8.2'
|
|
29
29
|
spec.add_dependency 'builder' , '>= 3.2.2'
|
|
30
30
|
spec.add_dependency 'globalid' , '~> 0.3'
|
|
31
|
-
spec.add_dependency 'statsd-ruby' , '~> 1.
|
|
31
|
+
spec.add_dependency 'statsd-ruby' , '~> 1.4.0'
|
|
32
|
+
spec.add_dependency 'thwait' , '~> 0.2'
|
|
33
|
+
|
|
32
34
|
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.3.
|
|
4
|
+
version: 0.3.16
|
|
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: 2021-02-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: redis
|
|
@@ -114,14 +114,28 @@ dependencies:
|
|
|
114
114
|
requirements:
|
|
115
115
|
- - "~>"
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: 1.
|
|
117
|
+
version: 1.4.0
|
|
118
118
|
type: :runtime
|
|
119
119
|
prerelease: false
|
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements:
|
|
122
122
|
- - "~>"
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: 1.
|
|
124
|
+
version: 1.4.0
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: thwait
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0.2'
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0.2'
|
|
125
139
|
description: Simple process orchestration
|
|
126
140
|
email:
|
|
127
141
|
- virtualstaticvoid@gmail.com
|
|
@@ -232,8 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
232
246
|
- !ruby/object:Gem::Version
|
|
233
247
|
version: '0'
|
|
234
248
|
requirements: []
|
|
235
|
-
|
|
236
|
-
rubygems_version: 2.5.1
|
|
249
|
+
rubygems_version: 3.1.4
|
|
237
250
|
signing_key:
|
|
238
251
|
specification_version: 4
|
|
239
252
|
summary: A simple orchestration library for running complex processes or workflows
|