Module: Floe::Workflow::States::ChildWorkflowMixin
Instance Method Summary collapse
- #each_child_context(context) ⇒ Object
- #ended?(context) ⇒ Boolean
- #finish(context) ⇒ Object
- #ready?(context) ⇒ Boolean
- #run_nonblock!(context) ⇒ Object
- #running?(context) ⇒ Boolean
- #success?(context) ⇒ Boolean
- #wait_until(context) ⇒ Object
- #waiting?(context) ⇒ Boolean
Instance Method Details
#each_child_context(context) ⇒ Object
51 52 53 |
# File 'lib/floe/workflow/states/child_workflow_mixin.rb', line 51 def each_child_context(context) context.state[child_context_key].map { |ctx| Context.new(ctx) } end |
#ended?(context) ⇒ Boolean
43 44 45 |
# File 'lib/floe/workflow/states/child_workflow_mixin.rb', line 43 def ended?(context) each_child_context(context).all?(&:ended?) end |
#finish(context) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/floe/workflow/states/child_workflow_mixin.rb', line 15 def finish(context) if success?(context) result = each_child_context(context).map(&:output) context.output = process_output(context, result) else error = parse_error(context) retry_state!(context, error) || catch_error!(context, error) || fail_workflow!(context, error) end super end |
#ready?(context) ⇒ Boolean
27 28 29 |
# File 'lib/floe/workflow/states/child_workflow_mixin.rb', line 27 def ready?(context) !context.state_started? || each_child_workflow(context).any? { |wf, ctx| wf.step_nonblock_ready?(ctx) } end |
#run_nonblock!(context) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/floe/workflow/states/child_workflow_mixin.rb', line 7 def run_nonblock!(context) start(context) unless context.state_started? step_nonblock!(context) return Errno::EAGAIN unless ready?(context) finish(context) if ended?(context) end |
#running?(context) ⇒ Boolean
39 40 41 |
# File 'lib/floe/workflow/states/child_workflow_mixin.rb', line 39 def running?(context) !ended?(context) end |
#success?(context) ⇒ Boolean
47 48 49 |
# File 'lib/floe/workflow/states/child_workflow_mixin.rb', line 47 def success?(context) each_child_context(context).none?(&:failed?) end |
#wait_until(context) ⇒ Object
31 32 33 |
# File 'lib/floe/workflow/states/child_workflow_mixin.rb', line 31 def wait_until(context) each_child_workflow(context).filter_map { |wf, ctx| wf.wait_until(ctx) }.min end |
#waiting?(context) ⇒ Boolean
35 36 37 |
# File 'lib/floe/workflow/states/child_workflow_mixin.rb', line 35 def waiting?(context) each_child_workflow(context).any? { |wf, ctx| wf.waiting?(ctx) } end |