Class: AWS::Flow::Templates::RootTemplate
- Inherits:
-
TemplateBase
- Object
- TemplateBase
- AWS::Flow::Templates::RootTemplate
- Defined in:
- lib/aws/templates/base.rb
Overview
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.
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#result_step ⇒ Object
Returns the value of attribute result_step.
-
#step ⇒ Object
readonly
Returns the value of attribute step.
Instance Method Summary collapse
-
#initialize(step, result_step) ⇒ RootTemplate
constructor
A new instance of RootTemplate.
-
#run(input, context) ⇒ Object
Calls the run method on the step (top level template).
Constructor Details
#initialize(step, result_step) ⇒ RootTemplate
Returns a new instance of RootTemplate.
32 33 34 35 |
# File 'lib/aws/templates/base.rb', line 32 def initialize(step, result_step) @step = step @result_step = result_step end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
29 30 31 |
# File 'lib/aws/templates/base.rb', line 29 def input @input end |
#result_step ⇒ Object
Returns the value of attribute result_step.
30 31 32 |
# File 'lib/aws/templates/base.rb', line 30 def result_step @result_step end |
#step ⇒ Object (readonly)
Returns the value of attribute step.
29 30 31 |
# File 'lib/aws/templates/base.rb', line 29 def step @step end |
Instance Method Details
#run(input, context) ⇒ Object
Calls the run method on the step (top level template). Manages overall error handling and reporting of results for the workflow
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# 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 |