taskinator 0.3.15 → 0.3.16

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: ffc2664d7ab51f381c4de1671eb127df7ecbab5629e2941fc7015bc11c70e2d0
4
- data.tar.gz: cb5f4a17be38e6f62b7ea3901b53af02e55216827c4f95518ba4fefcfb8e0d25
3
+ metadata.gz: 231c6c9f1bdcf8bb1a7fb38c0ebd0c893f61f49051d94ace5714233a207ad651
4
+ data.tar.gz: 9c66bf91f8420f3fff69487e095a5c36986409f7249224f03ba0b53fdd427190
5
5
  SHA512:
6
- metadata.gz: 64e1c2b5e62469d1d6328dcb3bf6b8738171e5d5b6335694092107bac16a3c7dd464dec35c8fd482e8b41e5bbe6369a6c3db9ade1b47b24c9a814aba8af56ed2
7
- data.tar.gz: cb91edc3acfff89281b35983f907dfdb2eb11d1b6760f9da334465d9f4e548b3069533bdd0d5b262368ab8b955002536830da8031929cec15655ec2e24d2e1d1
6
+ metadata.gz: 0e322ccc3214ed171bd75b14b4ebaa7e51c1e1ba33b3f7f292c707059f166566a8b8c08235442d26922b0cd8a8c2affa320af03d069d33b0fce4d9ffe7485e95
7
+ data.tar.gz: d16a3220d1be357c77e7a47d3e2c426a99549c3d350979f534a176ec3919444551956d4d41e6b7389e245fe39c1286d7ef60e6f07b1155f3aeae7e9cdce1398b
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.5.1
1
+ ruby-2.7.2
data/.travis.yml CHANGED
@@ -6,10 +6,10 @@ services:
6
6
  - redis-server
7
7
 
8
8
  rvm:
9
- - 2.2.10
10
- - 2.3.7
11
- - 2.4.4
12
- - 2.5.1
9
+ - 2.4.10
10
+ - 2.5.8
11
+ - 2.6.6
12
+ - 2.7.2
13
13
 
14
14
  script: 'bundle exec rake spec'
15
15
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- taskinator (0.3.15)
4
+ taskinator (0.3.16)
5
5
  builder (>= 3.2.2)
6
6
  connection_pool (>= 2.2.0)
7
7
  globalid (~> 0.3)
@@ -10,54 +10,57 @@ PATH
10
10
  redis-namespace (>= 1.5.2)
11
11
  redis-semaphore (>= 0.2.4)
12
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 (5.2.1)
18
+ activesupport (5.2.4.5)
18
19
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
20
  i18n (>= 0.7, < 2)
20
21
  minitest (~> 5.1)
21
22
  tzinfo (~> 1.1)
22
- builder (3.2.3)
23
- byebug (10.0.2)
24
- coderay (1.1.2)
25
- concurrent-ruby (1.1.3)
26
- connection_pool (2.2.2)
27
- coveralls (0.8.22)
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)
28
29
  json (>= 1.8, < 3)
29
30
  simplecov (~> 0.16.1)
30
31
  term-ansicolor (~> 1.3)
31
- thor (~> 0.19.4)
32
+ thor (>= 0.19.4, < 2.0)
32
33
  tins (~> 1.6)
33
- delayed_job (4.1.5)
34
- activesupport (>= 3.0, < 5.3)
35
- diff-lcs (1.3)
36
- docile (1.3.1)
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)
37
39
  fakeredis (0.7.0)
38
40
  redis (>= 3.2, < 5.0)
39
- globalid (0.4.1)
41
+ globalid (0.4.2)
40
42
  activesupport (>= 4.2.0)
41
- i18n (1.1.1)
43
+ i18n (1.8.9)
42
44
  concurrent-ruby (~> 1.0)
43
- json (2.1.0)
44
- method_source (0.9.2)
45
- minitest (5.11.3)
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.13.1)
48
- mustermann (1.0.3)
49
- pry (0.12.2)
50
- coderay (~> 1.1.0)
51
- method_source (~> 0.9.0)
52
- pry-byebug (3.6.0)
53
- byebug (~> 10.0)
54
- pry (~> 0.10)
55
- rack (2.0.6)
56
- rack-protection (2.0.4)
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 (12.3.1)
59
- redis (4.0.3)
60
- redis-namespace (1.6.0)
61
+ rake (13.0.3)
62
+ redis (4.2.5)
63
+ redis-namespace (1.8.1)
61
64
  redis (>= 3.0.4)
62
65
  redis-semaphore (0.3.1)
63
66
  redis
@@ -72,44 +75,49 @@ GEM
72
75
  rspec-core (>= 3.0.0)
73
76
  rspec-expectations (>= 3.0.0)
74
77
  rspec-mocks (>= 3.0.0)
75
- rspec (3.8.0)
76
- rspec-core (~> 3.8.0)
77
- rspec-expectations (~> 3.8.0)
78
- rspec-mocks (~> 3.8.0)
79
- rspec-core (3.8.0)
80
- rspec-support (~> 3.8.0)
81
- rspec-expectations (3.8.2)
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.8.0)
84
- rspec-mocks (3.8.0)
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.8.0)
87
- rspec-sidekiq (3.0.3)
89
+ rspec-support (~> 3.10.0)
90
+ rspec-sidekiq (3.1.0)
88
91
  rspec-core (~> 3.0, >= 3.0.0)
89
92
  sidekiq (>= 2.4.0)
90
- rspec-support (3.8.0)
91
- sidekiq (5.2.3)
92
- connection_pool (~> 2.2, >= 2.2.2)
93
- rack-protection (>= 1.5.0)
94
- redis (>= 3.3.5, < 5)
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)
95
99
  simplecov (0.16.1)
96
100
  docile (~> 1.1)
97
101
  json (>= 1.8, < 3)
98
102
  simplecov-html (~> 0.10.0)
99
103
  simplecov-html (0.10.2)
100
- sinatra (2.0.4)
104
+ sinatra (2.1.0)
101
105
  mustermann (~> 1.0)
102
- rack (~> 2.0)
103
- rack-protection (= 2.0.4)
106
+ rack (~> 2.2)
107
+ rack-protection (= 2.1.0)
104
108
  tilt (~> 2.0)
105
109
  statsd-ruby (1.4.0)
106
- term-ansicolor (1.7.0)
110
+ sync (0.5.0)
111
+ term-ansicolor (1.7.1)
107
112
  tins (~> 1.0)
108
- thor (0.19.4)
113
+ thor (1.1.0)
109
114
  thread_safe (0.3.6)
110
- tilt (2.0.8)
111
- tins (1.20.2)
112
- tzinfo (1.2.5)
115
+ thwait (0.2.0)
116
+ e2mmap
117
+ tilt (2.0.10)
118
+ tins (1.28.0)
119
+ sync
120
+ tzinfo (1.2.9)
113
121
  thread_safe (~> 0.1)
114
122
  vegas (0.1.11)
115
123
  rack (>= 1.0.0)
@@ -134,4 +142,4 @@ DEPENDENCIES
134
142
  taskinator!
135
143
 
136
144
  BUNDLED WITH
137
- 1.17.1
145
+ 2.2.11
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Taskinator
2
- VERSION = "0.3.15"
2
+ VERSION = "0.3.16"
3
3
  end
@@ -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
- allow(process).to receive(:deincr_pending_tasks) { tasks.count - 1 }
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
data/taskinator.gemspec CHANGED
@@ -29,4 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'builder' , '>= 3.2.2'
30
30
  spec.add_dependency 'globalid' , '~> 0.3'
31
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.15
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: 2018-11-22 00:00:00.000000000 Z
11
+ date: 2021-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
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
- rubyforge_project:
236
- rubygems_version: 2.7.7
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