taskinator 0.4.7 → 0.5.0

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: 0ea786056f74987f21643d392336032d09896df7ddc01d462a78a257a19088d8
4
- data.tar.gz: f693f14e2dac9341f1c83c6bf04b12da9d96261498198cc712e71be5b4b51955
3
+ metadata.gz: ae9476e48721568bd268135aac66ccf70f0b1f9f5737e2db7c25ab22033e6e3b
4
+ data.tar.gz: bba571d2cc60c017636187a88cd770889c5ac644726ac4094134d6ea48a9decd
5
5
  SHA512:
6
- metadata.gz: 6151322f48c6215c41ffeeb6fc08d43aa871f9f76d04f628c80d29fa423b22fb0a3ee589803efd1503c3b59491bc4e2ace36879f801638898b9ace0557e4f180
7
- data.tar.gz: 65ba806d211f62c8ff12ea3c036b037f53567a17f1a848129ba8f737d4fc0267be7435d6e315591afa81527275042bf22cc04066c74684b6cc54b0e3ce8691f8
6
+ metadata.gz: 5d2912f45a9200d3f2abce1cc4fd651b2369d0663cbad219e0e16fe08990ad0f9ecdbf49402d5d2774581dd111fd0b3141f2bbe939214114094de13f3eae7d8e
7
+ data.tar.gz: dd35c73baf37a5ba20bc43faebeb855fa5445c0559f331c7f8c144d0d5fcb27c05b0e72b8030d31a42b985d5322a8e539db8113c0b43341b41bbde2a8c8cfb2f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ v0.5.0 - 18 Feb 2022
2
+ ---
3
+ Removed unused `ProcessWorker` class and related queue methods.
4
+ Refactored `TestQueueAdapter` to correctly implement queue adapter for use in specs.
5
+ Added deprecation for `Taskinator::Process::Concurrent#concurrency_method` option.
6
+
7
+ v0.4.7 - 17 Feb 2022
8
+ ---
9
+ Use newer format for `pipelined` and `multi` requests in Redis.
10
+
11
+ v0.4.6 - 12 Feb 2022
12
+ ---
13
+ Upgrade actionpack for [information vulnerability fix](https://github.com/virtualstaticvoid/taskinator/security/dependabot/3).
14
+
15
+ v0.4.5 - 30 Jan 2022
16
+ ---
17
+ Upgrade sidekiq dependency for [CVE-2022-23837](https://github.com/advisories/GHSA-jrfj-98qg-qjgv).
18
+
1
19
  v0.4.4 - 17 Jan 2022
2
20
  ---
3
21
  Add support for `ActiveJob`.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- taskinator (0.4.7)
4
+ taskinator (0.5.0)
5
5
  builder (>= 3.2.2)
6
6
  connection_pool (>= 2.2.0)
7
7
  globalid (~> 0.3)
@@ -222,12 +222,15 @@ module Taskinator
222
222
 
223
223
  class Concurrent < Process
224
224
  attr_reader :complete_on
225
+
226
+ # <b>DEPRECATED:</b> concurrency_method will be removed in a future version.
225
227
  attr_reader :concurrency_method
226
228
 
227
229
  def initialize(definition, complete_on=CompleteOn::Default, options={})
228
230
  super(definition, options)
229
231
  @complete_on = complete_on
230
232
  @concurrency_method = options.delete(:concurrency_method) || :thread
233
+ warn("[DEPRECATED]: concurrency_method will be removed in a future version.") if @concurrency_method == :fork
231
234
  end
232
235
 
233
236
  def enqueue
@@ -246,6 +249,7 @@ module Taskinator
246
249
  complete! # weren't any tasks to start with
247
250
  else
248
251
  if concurrency_method == :fork
252
+ warn("[DEPRECATED]: concurrency_method will be removed in a future version.")
249
253
  tasks.each do |task|
250
254
  fork do
251
255
  task.start!
@@ -18,12 +18,6 @@ module Taskinator
18
18
  .perform_later(definition.name, uuid, Taskinator::Persistence.serialize(args))
19
19
  end
20
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
21
  def enqueue_task(task)
28
22
  queue = task.queue || @config[:task_queue]
29
23
  TaskWorker.set(:queue => queue)
@@ -36,12 +30,6 @@ module Taskinator
36
30
  end
37
31
  end
38
32
 
39
- class ProcessWorker < ApplicationJob
40
- def perform(process_uuid)
41
- Taskinator::ProcessWorker.new(process_uuid).perform
42
- end
43
- end
44
-
45
33
  class TaskWorker < ApplicationJob
46
34
  def perform(task_uuid)
47
35
  Taskinator::TaskWorker.new(task_uuid).perform
@@ -17,11 +17,6 @@ module Taskinator
17
17
  ::Delayed::Job.enqueue CreateProcessWorker.new(definition.name, uuid, Taskinator::Persistence.serialize(args)), :queue => queue
18
18
  end
19
19
 
20
- def enqueue_process(process)
21
- queue = process.queue || @config[:process_queue]
22
- ::Delayed::Job.enqueue ProcessWorker.new(process.uuid), :queue => queue
23
- end
24
-
25
20
  def enqueue_task(task)
26
21
  queue = task.queue || @config[:task_queue]
27
22
  ::Delayed::Job.enqueue TaskWorker.new(task.uuid), :queue => queue
@@ -33,12 +28,6 @@ module Taskinator
33
28
  end
34
29
  end
35
30
 
36
- ProcessWorker = Struct.new(:process_uuid) do
37
- def perform
38
- Taskinator::ProcessWorker.new(process_uuid).perform
39
- end
40
- end
41
-
42
31
  TaskWorker = Struct.new(:task_uuid) do
43
32
  def perform
44
33
  Taskinator::TaskWorker.new(task_uuid).perform
@@ -15,10 +15,6 @@ module Taskinator
15
15
  @queue = config[:definition_queue]
16
16
  end
17
17
 
18
- ProcessWorker.class_eval do
19
- @queue = config[:process_queue]
20
- end
21
-
22
18
  TaskWorker.class_eval do
23
19
  @queue = config[:task_queue]
24
20
  end
@@ -30,11 +26,6 @@ module Taskinator
30
26
  Resque.enqueue_to(queue, CreateProcessWorker, definition.name, uuid, Taskinator::Persistence.serialize(args))
31
27
  end
32
28
 
33
- def enqueue_process(process)
34
- queue = process.queue || Resque.queue_from_class(ProcessWorker)
35
- Resque.enqueue_to(queue, ProcessWorker, process.uuid)
36
- end
37
-
38
29
  def enqueue_task(task)
39
30
  queue = task.queue || Resque.queue_from_class(TaskWorker)
40
31
  Resque.enqueue_to(queue, TaskWorker, task.uuid)
@@ -46,12 +37,6 @@ module Taskinator
46
37
  end
47
38
  end
48
39
 
49
- class ProcessWorker
50
- def self.perform(process_uuid)
51
- Taskinator::ProcessWorker.new(process_uuid).perform
52
- end
53
- end
54
-
55
40
  class TaskWorker
56
41
  def self.perform(task_uuid)
57
42
  Taskinator::TaskWorker.new(task_uuid).perform
@@ -17,11 +17,6 @@ module Taskinator
17
17
  CreateProcessWorker.client_push('class' => CreateProcessWorker, 'args' => [definition.name, uuid, Taskinator::Persistence.serialize(args)], 'queue' => queue)
18
18
  end
19
19
 
20
- def enqueue_process(process)
21
- queue = process.queue || @config[:process_queue]
22
- TaskWorker.client_push('class' => ProcessWorker, 'args' => [process.uuid], 'queue' => queue)
23
- end
24
-
25
20
  def enqueue_task(task)
26
21
  queue = task.queue || @config[:task_queue]
27
22
  TaskWorker.client_push('class' => TaskWorker, 'args' => [task.uuid], 'queue' => queue)
@@ -35,14 +30,6 @@ module Taskinator
35
30
  end
36
31
  end
37
32
 
38
- class ProcessWorker
39
- include ::Sidekiq::Worker
40
-
41
- def perform(process_uuid)
42
- Taskinator::ProcessWorker.new(process_uuid).perform
43
- end
44
- end
45
-
46
33
  class TaskWorker
47
34
  include ::Sidekiq::Worker
48
35
 
@@ -33,11 +33,6 @@ module Taskinator
33
33
  adapter.enqueue_create_process(definition, uuid, args)
34
34
  end
35
35
 
36
- def enqueue_process(process)
37
- Taskinator.logger.info("Enqueuing process #{process}")
38
- adapter.enqueue_process(process)
39
- end
40
-
41
36
  def enqueue_task(task)
42
37
  Taskinator.logger.info("Enqueuing task #{task}")
43
38
  adapter.enqueue_task(task)
@@ -1,3 +1,3 @@
1
1
  module Taskinator
2
- VERSION = "0.4.7"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/taskinator.rb CHANGED
@@ -26,7 +26,6 @@ require 'taskinator/tasks'
26
26
  require 'taskinator/process'
27
27
 
28
28
  require 'taskinator/task_worker'
29
- require 'taskinator/process_worker'
30
29
  require 'taskinator/create_process_worker'
31
30
 
32
31
  require 'taskinator/executor'
@@ -2,38 +2,42 @@ module Taskinator
2
2
  module Queues
3
3
 
4
4
  def self.create_test_queue_adapter(config={})
5
- TestQueueAdapter.new
5
+ TestQueueAdapter.new(config)
6
6
  end
7
7
 
8
8
  def self.create_test_queue_worker_adapter(config={})
9
- QueueWorkerAdapter.new
9
+ TestQueueWorkerAdapter.new(config)
10
10
  end
11
11
 
12
+ #
13
+ # this is a no-op adapter, it tracks enqueued processes and tasks
14
+ #
12
15
  class TestQueueAdapter
13
16
 
14
- attr_reader :creates
15
- attr_reader :tasks
16
-
17
- def initialize
17
+ def initialize(config={})
18
18
  clear
19
19
  end
20
20
 
21
- def clear
22
- @creates = []
23
- @tasks = []
24
- @jobs = []
25
- end
26
-
27
21
  def enqueue_create_process(definition, uuid, args)
28
- @creates << [definition, uuid, args]
22
+ @processes << [definition, uuid, args]
29
23
  end
30
24
 
31
25
  def enqueue_task(task)
32
26
  @tasks << task
33
27
  end
34
28
 
29
+ # helpers
30
+
31
+ attr_reader :processes
32
+ attr_reader :tasks
33
+
34
+ def clear
35
+ @processes = []
36
+ @tasks = []
37
+ end
38
+
35
39
  def empty?
36
- @creates.empty? && @tasks.empty? && @jobs.empty?
40
+ @processes.empty? && @tasks.empty?
37
41
  end
38
42
 
39
43
  end
@@ -41,7 +45,7 @@ module Taskinator
41
45
  #
42
46
  # this is a "synchronous" implementation for use in testing
43
47
  #
44
- class QueueWorkerAdapter < TestQueueAdapter
48
+ class TestQueueWorkerAdapter < TestQueueAdapter
45
49
 
46
50
  def enqueue_create_process(definition, uuid, args)
47
51
  super
@@ -57,6 +61,8 @@ module Taskinator
57
61
  end
58
62
  end
59
63
 
64
+ private
65
+
60
66
  def invoke(&block)
61
67
  block.call
62
68
  end
@@ -156,7 +156,7 @@ describe Taskinator::Definition do
156
156
  # if an error is raised, then the context was incorrect
157
157
  expect {
158
158
  subject.create_process
159
- }.to_not raise_error(StandardError)
159
+ }.not_to raise_error
160
160
  end
161
161
 
162
162
  context "is instrumented" do
@@ -35,27 +35,6 @@ describe Taskinator::Queues::ActiveJobAdapter, :active_job do
35
35
  end
36
36
  end
37
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
38
  describe "TaskWorker" do
60
39
  it "enqueues tasks" do
61
40
  worker = adapter::TaskWorker
@@ -30,24 +30,6 @@ describe Taskinator::Queues::DelayedJobAdapter, :delayed_job do
30
30
  end
31
31
  end
32
32
 
33
- describe "ProcessWorker" do
34
- it "enqueues processes" do
35
- expect {
36
- subject.enqueue_process(double('process', :uuid => uuid, :queue => nil))
37
- }.to change(Delayed::Job.queue, :size).by(1)
38
- end
39
-
40
- it "enqueues process to specified queue" do
41
- subject.enqueue_process(double('process', :uuid => uuid, :queue => :other))
42
- expect(Delayed::Job.contains?(adapter::ProcessWorker, uuid, :other)).to be
43
- end
44
-
45
- it "calls process worker" do
46
- expect_any_instance_of(Taskinator::ProcessWorker).to receive(:perform)
47
- adapter::ProcessWorker.new(uuid).perform
48
- end
49
- end
50
-
51
33
  describe "TaskWorker" do
52
34
  it "enqueues tasks" do
53
35
  expect {
@@ -34,27 +34,6 @@ describe Taskinator::Queues::ResqueAdapter, :resque do
34
34
  end
35
35
  end
36
36
 
37
- describe "ProcessWorker" do
38
- it "enqueues processes" do
39
- worker = adapter::ProcessWorker
40
- subject.enqueue_process(double('process', :uuid => uuid, :queue => nil))
41
-
42
- expect(worker).to have_queued(uuid)
43
- end
44
-
45
- it "enqueues process to specified queue" do
46
- worker = adapter::ProcessWorker
47
- subject.enqueue_process(double('process', :uuid => uuid, :queue => :other))
48
-
49
- expect(worker).to have_queued(uuid).in(:other)
50
- end
51
-
52
- it "calls process worker" do
53
- expect_any_instance_of(Taskinator::ProcessWorker).to receive(:perform)
54
- adapter::ProcessWorker.perform(uuid)
55
- end
56
- end
57
-
58
37
  describe "TaskWorker" do
59
38
  it "enqueues tasks" do
60
39
  worker = adapter::TaskWorker
@@ -33,25 +33,6 @@ describe Taskinator::Queues::SidekiqAdapter, :sidekiq do
33
33
  end
34
34
  end
35
35
 
36
- describe "ProcessWorker" do
37
- it "enqueues processes" do
38
- worker = adapter::ProcessWorker
39
- process = double('process', :uuid => uuid, :queue => nil)
40
- subject.enqueue_process(process)
41
- expect(worker).to have_enqueued_sidekiq_job(process.uuid)
42
- end
43
-
44
- it "enqueues process to specified queue" do
45
- subject.enqueue_process(double('process', :uuid => uuid, :queue => :other))
46
- expect(adapter::ProcessWorker).to be_processed_in_x(:other)
47
- end
48
-
49
- it "calls process worker" do
50
- expect_any_instance_of(Taskinator::ProcessWorker).to receive(:perform)
51
- adapter::ProcessWorker.new.perform(uuid)
52
- end
53
- end
54
-
55
36
  describe "TaskWorker" do
56
37
  it "enqueues tasks" do
57
38
  worker = adapter::TaskWorker
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Taskinator::Queues::TestQueueAdapter do
4
+
5
+ # sanity check for the test adapter
6
+
7
+ it_should_behave_like "a queue adapter", :test_queue, Taskinator::Queues::TestQueueAdapter
8
+
9
+ end
@@ -98,10 +98,14 @@ describe TestFlows do
98
98
  let(:definition) { TestFlows::EmptySequentialProcessTest }
99
99
  subject { definition.create_process }
100
100
 
101
+ it "contains 3 tasks" do
102
+ expect(subject.tasks.length).to eq(3)
103
+ end
104
+
101
105
  it "invokes each task" do
102
- # this doesn't work...
103
- # expect_any_instance_of(Taskinator::Executor).to receive(:do_task_x).exactly(3).times
104
- # subject.start!
106
+ expect_any_instance_of(definition).to receive(:task_0)
107
+ expect_any_instance_of(definition).to receive(:task_1)
108
+ expect_any_instance_of(definition).to receive(:task_2)
105
109
 
106
110
  expect {
107
111
  subject.enqueue!
@@ -113,10 +117,14 @@ describe TestFlows do
113
117
  let(:definition) { TestFlows::EmptyConcurrentProcessTest }
114
118
  subject { definition.create_process }
115
119
 
120
+ it "contains 3 tasks" do
121
+ expect(subject.tasks.length).to eq(3)
122
+ end
123
+
116
124
  it "invokes each task" do
117
- # this doesn't work...
118
- # expect_any_instance_of(Taskinator::Executor).to receive(:do_task_x).exactly(3).times
119
- # subject.start!
125
+ expect_any_instance_of(definition).to receive(:task_0)
126
+ expect_any_instance_of(definition).to receive(:task_1)
127
+ expect_any_instance_of(definition).to receive(:task_2)
120
128
 
121
129
  expect {
122
130
  subject.enqueue!
@@ -173,11 +181,11 @@ describe TestFlows do
173
181
  end
174
182
 
175
183
  describe "job" do
176
-
184
+ pending
177
185
  end
178
186
 
179
187
  describe "subprocess" do
180
-
188
+ pending
181
189
  end
182
190
  end
183
191
 
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.7
4
+ version: 0.5.0
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-02-17 00:00:00.000000000 Z
11
+ date: 2022-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -161,7 +161,6 @@ files:
161
161
  - lib/taskinator/logger.rb
162
162
  - lib/taskinator/persistence.rb
163
163
  - lib/taskinator/process.rb
164
- - lib/taskinator/process_worker.rb
165
164
  - lib/taskinator/queues.rb
166
165
  - lib/taskinator/queues/active_job.rb
167
166
  - lib/taskinator/queues/delayed_job.rb
@@ -204,11 +203,11 @@ files:
204
203
  - spec/taskinator/instrumentation_spec.rb
205
204
  - spec/taskinator/persistence_spec.rb
206
205
  - spec/taskinator/process_spec.rb
207
- - spec/taskinator/process_worker_spec.rb
208
206
  - spec/taskinator/queues/active_job_spec.rb
209
207
  - spec/taskinator/queues/delayed_job_spec.rb
210
208
  - spec/taskinator/queues/resque_spec.rb
211
209
  - spec/taskinator/queues/sidekiq_spec.rb
210
+ - spec/taskinator/queues/test_queue_adapter_spec.rb
212
211
  - spec/taskinator/queues_spec.rb
213
212
  - spec/taskinator/task_spec.rb
214
213
  - spec/taskinator/task_worker_spec.rb
@@ -271,11 +270,11 @@ test_files:
271
270
  - spec/taskinator/instrumentation_spec.rb
272
271
  - spec/taskinator/persistence_spec.rb
273
272
  - spec/taskinator/process_spec.rb
274
- - spec/taskinator/process_worker_spec.rb
275
273
  - spec/taskinator/queues/active_job_spec.rb
276
274
  - spec/taskinator/queues/delayed_job_spec.rb
277
275
  - spec/taskinator/queues/resque_spec.rb
278
276
  - spec/taskinator/queues/sidekiq_spec.rb
277
+ - spec/taskinator/queues/test_queue_adapter_spec.rb
279
278
  - spec/taskinator/queues_spec.rb
280
279
  - spec/taskinator/task_spec.rb
281
280
  - spec/taskinator/task_worker_spec.rb
@@ -1,13 +0,0 @@
1
- module Taskinator
2
- class ProcessWorker
3
- attr_reader :uuid
4
-
5
- def initialize(uuid)
6
- @uuid = uuid
7
- end
8
-
9
- def perform
10
- # TODO: build the process, and enqueue it. after it completes, report back to the containing process
11
- end
12
- end
13
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Taskinator::ProcessWorker do
4
- pending
5
- end