Sha256: 080f340614ad4910fb34b0a62af7146de8c5b54250650305924530e3fa5be753
Contents?: true
Size: 1.35 KB
Versions: 9
Compression:
Stored size: 1.35 KB
Contents
module Kuroko2 module Workflow module Task class Fork < Base def execute children = token.children if children.empty? message = "(token #{token.uuid}) Start to fork." token.job_instance.logs.info(message) Kuroko2.logger.info(message) node.children.each do |child| attributes = token.attributes.except('id', 'uuid', 'script', 'path', 'message', 'created_at', 'updated_at') attributes = attributes.merge(uuid: SecureRandom.uuid, parent: token, script: child.to_script, path: '/') Token.create!(attributes).tap do |created| message = "(token #{created.uuid}) New token are created for #{node.path}" created.job_instance.logs.info(message) Kuroko2.logger.info(message) end end :pass elsif children.all?(&:finished?) message = "(token #{token.uuid}) All children are finished." token.job_instance.logs.info(message) Kuroko2.logger.info(message) :next_sibling else :pass end end def validate if node.children.empty? raise Workflow::AssertionError, "Fork must have children node" end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems