Class: Kuroko2::Workflow::Task::Fork

Inherits:
Base
  • Object
show all
Defined in:
lib/autoload/kuroko2/workflow/task/fork.rb

Direct Known Subclasses

ParallelFork

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Kuroko2::Workflow::Task::Base

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/autoload/kuroko2/workflow/task/fork.rb', line 5

def execute
  if fork_children_ids.empty?
    message = "(token #{token.uuid}) Start to fork."

    token.job_instance.logs.info(message)
    Kuroko2.logger.info(message)
    extract_child_nodes

    :pass
  elsif token.children.where(id: fork_children_ids).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

#validateObject



26
27
28
29
30
# File 'lib/autoload/kuroko2/workflow/task/fork.rb', line 26

def validate
  if node.children.empty?
    raise Workflow::AssertionError, "#{self.class} must have children node"
  end
end