class AWS::Flow::Templates::RootTemplate
Root template is the top level template that is sent to a workflow to run. It contains a step (which is another template) that it passes the input and the context to. It also contains a result_step
that it uses to report the result of the workflow.
Attributes
input[R]
result_step[RW]
step[R]
Public Class Methods
new(step, result_step)
click to toggle source
# File lib/aws/templates/base.rb, line 32 def initialize(step, result_step) @step = step @result_step = result_step end
Public Instance Methods
run(input, context)
click to toggle source
Calls the run method on the step (top level template). Manages overall error handling and reporting of results for the workflow
# File lib/aws/templates/base.rb, line 39 def run(input, context) result = nil failure = nil begin result = @step.run(input, context) rescue Exception => e failure = e ensure if failure # If there is a result_step, pass the failure as an input to it. @result_step.run({failure: failure}, context) if @result_step # Now fail the workflow raise e else # Pass the result as an input to the result_step @result_step.run(result, context) if @result_step # Complete the workflow by returning the result result end end end