taskinator 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/taskinator/persistence.rb +125 -1
- data/lib/taskinator/process.rb +1 -0
- data/lib/taskinator/task.rb +1 -0
- data/lib/taskinator/version.rb +1 -1
- data/lib/taskinator/workflow.rb +2 -2
- data/spec/taskinator/persistence_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cac7446426c45fc14b6cc0dee7620874e322fa2
|
4
|
+
data.tar.gz: 7dd667765ef5e6a139b99ea03604aef198f80130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de3cc2b3dd447ed10b1662cca01ea0398c35c375466ee3a55b3ed67eefc28cd1a8d5888e56f50258bc2027f7ea4f8462ba0bc52cac2d2f242dbd56b46b7548b4
|
7
|
+
data.tar.gz: c98d31d5968ecfc7289831b327a1fd00bb9be75c0206304f3d8aed6b38fbf3ec4d3460b85b3cf439604ea2490095d8fee60280c27c43a18b71c6a9b3aa47d03c
|
data/Gemfile.lock
CHANGED
@@ -68,6 +68,15 @@ module Taskinator
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def to_xml
|
72
|
+
builder = ::Builder::XmlMarkup.new
|
73
|
+
builder.instruct!
|
74
|
+
builder.tag!('process', :key => self.key) do |xml|
|
75
|
+
XmlSerializationVisitor.new(xml, self).visit
|
76
|
+
end
|
77
|
+
builder
|
78
|
+
end
|
79
|
+
|
71
80
|
# the persistence key
|
72
81
|
def key
|
73
82
|
@key ||= self.class.key_for(self.uuid)
|
@@ -262,7 +271,10 @@ module Taskinator
|
|
262
271
|
tasks.each do |task|
|
263
272
|
RedisSerializationVisitor.new(@conn, task, @base_visitor).visit
|
264
273
|
@conn.rpush "#{@key}:tasks", task.uuid
|
265
|
-
|
274
|
+
unless task.is_a?(Task::SubProcess)
|
275
|
+
incr_task_count unless self == @base_visitor
|
276
|
+
@base_visitor.incr_task_count
|
277
|
+
end
|
266
278
|
end
|
267
279
|
end
|
268
280
|
|
@@ -315,6 +327,118 @@ module Taskinator
|
|
315
327
|
end
|
316
328
|
end
|
317
329
|
|
330
|
+
class XmlSerializationVisitor < Taskinator::Visitor::Base
|
331
|
+
|
332
|
+
#
|
333
|
+
# the redis connection is passed in since it is
|
334
|
+
# in the multi statement mode in order to produce
|
335
|
+
# one roundtrip to the redis server
|
336
|
+
#
|
337
|
+
|
338
|
+
attr_reader :builder
|
339
|
+
attr_reader :instance
|
340
|
+
|
341
|
+
def initialize(builder, instance, base_visitor=self)
|
342
|
+
@builder = builder
|
343
|
+
@instance = instance
|
344
|
+
@key = instance.key
|
345
|
+
@root = base_visitor.instance
|
346
|
+
@base_visitor = base_visitor
|
347
|
+
@task_count = 0
|
348
|
+
end
|
349
|
+
|
350
|
+
# the starting point for serializing the instance
|
351
|
+
def visit
|
352
|
+
@attributes = []
|
353
|
+
@attributes << [:type, @instance.class.name]
|
354
|
+
@attributes << [:process_uuid, @root.uuid]
|
355
|
+
@attributes << [:state, :initial]
|
356
|
+
|
357
|
+
@instance.accept(self)
|
358
|
+
|
359
|
+
@attributes << [:task_count, @task_count]
|
360
|
+
|
361
|
+
@attributes.each do |(name, value)|
|
362
|
+
builder.tag!('attribute', name => value)
|
363
|
+
end
|
364
|
+
|
365
|
+
self
|
366
|
+
end
|
367
|
+
|
368
|
+
def visit_process(attribute)
|
369
|
+
process = @instance.send(attribute)
|
370
|
+
if process
|
371
|
+
@attributes << [attribute, process.uuid]
|
372
|
+
|
373
|
+
builder.tag!('process', :key => process.key) do |xml|
|
374
|
+
XmlSerializationVisitor.new(xml, process, @base_visitor).visit
|
375
|
+
end
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
def visit_tasks(tasks)
|
380
|
+
builder.tag!('tasks') do |xml|
|
381
|
+
tasks.each do |task|
|
382
|
+
xml.tag!('task', :key => task.key) do |xml2|
|
383
|
+
XmlSerializationVisitor.new(xml2, task, @base_visitor).visit
|
384
|
+
unless task.is_a?(Task::SubProcess)
|
385
|
+
incr_task_count unless self == @base_visitor
|
386
|
+
@base_visitor.incr_task_count
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
def visit_attribute(attribute)
|
394
|
+
value = @instance.send(attribute)
|
395
|
+
@attributes << [attribute, value] if value
|
396
|
+
end
|
397
|
+
|
398
|
+
def visit_attribute_time(attribute)
|
399
|
+
visit_attribute(attribute)
|
400
|
+
end
|
401
|
+
|
402
|
+
def visit_attribute_enum(attribute, type)
|
403
|
+
visit_attribute(attribute)
|
404
|
+
end
|
405
|
+
|
406
|
+
def visit_process_reference(attribute)
|
407
|
+
process = @instance.send(attribute)
|
408
|
+
@attributes << [attribute, process.uuid] if process
|
409
|
+
end
|
410
|
+
|
411
|
+
def visit_task_reference(attribute)
|
412
|
+
task = @instance.send(attribute)
|
413
|
+
@attributes << [attribute, task.uuid] if task
|
414
|
+
end
|
415
|
+
|
416
|
+
def visit_type(attribute)
|
417
|
+
type = @instance.send(attribute)
|
418
|
+
@attributes << [attribute, type.name] if type
|
419
|
+
end
|
420
|
+
|
421
|
+
def visit_args(attribute)
|
422
|
+
values = @instance.send(attribute)
|
423
|
+
yaml = Taskinator::Persistence.serialize(values)
|
424
|
+
|
425
|
+
# greater than 2 MB?
|
426
|
+
if (yaml.bytesize / (1024.0**2)) > 2
|
427
|
+
Taskinator.logger.warn("Large argument data detected for '#{self.to_s}'. Consider using intrinsic types instead, or try to reduce the amount of data provided.")
|
428
|
+
end
|
429
|
+
|
430
|
+
@attributes << [attribute, yaml]
|
431
|
+
end
|
432
|
+
|
433
|
+
def task_count
|
434
|
+
@task_count
|
435
|
+
end
|
436
|
+
|
437
|
+
def incr_task_count
|
438
|
+
@task_count += 1
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
318
442
|
class RedisDeserializationVisitor < Taskinator::Visitor::Base
|
319
443
|
|
320
444
|
#
|
data/lib/taskinator/process.rb
CHANGED
data/lib/taskinator/task.rb
CHANGED
data/lib/taskinator/version.rb
CHANGED
data/lib/taskinator/workflow.rb
CHANGED
@@ -2,11 +2,11 @@ module Taskinator
|
|
2
2
|
module Workflow
|
3
3
|
|
4
4
|
def current_state
|
5
|
-
|
6
|
-
@current_state = load_workflow_state
|
5
|
+
@current_state ||= load_workflow_state
|
7
6
|
end
|
8
7
|
|
9
8
|
def current_state=(new_state)
|
9
|
+
return if new_state == @current_state
|
10
10
|
@current_state = persist_workflow_state(new_state)
|
11
11
|
end
|
12
12
|
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Stefano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|