Class: Floe::Workflow::States::Parallel
- Inherits:
-
Floe::Workflow::State
- Object
- Floe::Workflow::State
- Floe::Workflow::States::Parallel
- Defined in:
- lib/floe/workflow/states/parallel.rb
Instance Attribute Summary collapse
-
#branches ⇒ Object
readonly
Returns the value of attribute branches.
-
#catch ⇒ Object
readonly
Returns the value of attribute catch.
-
#end ⇒ Object
readonly
Returns the value of attribute end.
-
#input_path ⇒ Object
readonly
Returns the value of attribute input_path.
-
#next ⇒ Object
readonly
Returns the value of attribute next.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#result_path ⇒ Object
readonly
Returns the value of attribute result_path.
-
#result_selector ⇒ Object
readonly
Returns the value of attribute result_selector.
-
#retry ⇒ Object
readonly
Returns the value of attribute retry.
Attributes inherited from Floe::Workflow::State
#comment, #name, #payload, #type
Instance Method Summary collapse
- #end? ⇒ Boolean
-
#initialize(workflow, name, payload) ⇒ Parallel
constructor
A new instance of Parallel.
- #start(context) ⇒ Object
Methods included from RetryCatchMixin
#catch_error!, #fail_workflow!, #find_catcher, #find_retrier, #retry_state!
Methods included from NonTerminalMixin
#finish, #validate_state_next!
Methods included from InputOutputMixin
#process_input, #process_output
Methods included from ChildWorkflowMixin
#each_child_context, #ended?, #finish, #ready?, #run_nonblock!, #running?, #success?, #wait_until, #waiting?
Methods inherited from Floe::Workflow::State
build!, #finish, #finished?, #long_name, #mark_error, #mark_finished, #mark_started, #ready?, #run_nonblock!, #running?, #short_name, #started?, #wait, #wait_until, #waiting?
Methods included from ValidationMixin
included, #invalid_field_error!, #missing_field_error!, #parser_error!, #runtime_field_error!, #workflow_state?, #wrap_parser_error
Constructor Details
#initialize(workflow, name, payload) ⇒ Parallel
Returns a new instance of Parallel.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/floe/workflow/states/parallel.rb', line 15 def initialize(workflow, name, payload) super missing_field_error!("Branches") if payload["Branches"].nil? @next = payload["Next"] @end = !!payload["End"] @parameters = PayloadTemplate.new(payload["Parameters"]) if payload["Parameters"] @input_path = Path.new(payload.fetch("InputPath", "$")) @output_path = Path.new(payload.fetch("OutputPath", "$")) @result_path = ReferencePath.new(payload.fetch("ResultPath", "$")) @result_selector = PayloadTemplate.new(payload["ResultSelector"]) if payload["ResultSelector"] @retry = payload["Retry"].to_a.map { |retrier| Retrier.new(retrier) } @catch = payload["Catch"].to_a.map { |catcher| Catcher.new(catcher) } @branches = payload["Branches"].map { |branch| Branch.new(branch) } validate_state!(workflow) end |
Instance Attribute Details
#branches ⇒ Object (readonly)
Returns the value of attribute branches.
12 13 14 |
# File 'lib/floe/workflow/states/parallel.rb', line 12 def branches @branches end |
#catch ⇒ Object (readonly)
Returns the value of attribute catch.
12 13 14 |
# File 'lib/floe/workflow/states/parallel.rb', line 12 def catch @catch end |
#end ⇒ Object (readonly)
Returns the value of attribute end.
12 13 14 |
# File 'lib/floe/workflow/states/parallel.rb', line 12 def end @end end |
#input_path ⇒ Object (readonly)
Returns the value of attribute input_path.
12 13 14 |
# File 'lib/floe/workflow/states/parallel.rb', line 12 def input_path @input_path end |
#next ⇒ Object (readonly)
Returns the value of attribute next.
12 13 14 |
# File 'lib/floe/workflow/states/parallel.rb', line 12 def next @next end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
12 13 14 |
# File 'lib/floe/workflow/states/parallel.rb', line 12 def output_path @output_path end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
12 13 14 |
# File 'lib/floe/workflow/states/parallel.rb', line 12 def parameters @parameters end |
#result_path ⇒ Object (readonly)
Returns the value of attribute result_path.
12 13 14 |
# File 'lib/floe/workflow/states/parallel.rb', line 12 def result_path @result_path end |
#result_selector ⇒ Object (readonly)
Returns the value of attribute result_selector.
12 13 14 |
# File 'lib/floe/workflow/states/parallel.rb', line 12 def result_selector @result_selector end |
#retry ⇒ Object (readonly)
Returns the value of attribute retry.
12 13 14 |
# File 'lib/floe/workflow/states/parallel.rb', line 12 def retry @retry end |
Instance Method Details
#end? ⇒ Boolean
42 43 44 |
# File 'lib/floe/workflow/states/parallel.rb', line 42 def end? @end end |
#start(context) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/floe/workflow/states/parallel.rb', line 34 def start(context) super input = process_input(context) context.state["BranchContext"] = branches.map { |_branch| Context.new({"Execution" => {"Id" => context.execution["Id"]}}, :input => input.to_json).to_h } end |