Extension: ParallelWithFinally State¶
The ParallelWithFinally
state extends the Parallel
state to provide a “finally” branch, which will be executed both for successful completion of the branches in the state, but also whenever a Catcher
is triggered due to an error in processing.
The “finally” branch will always be executed prior to the NextState
of either the parallel state or the catcher.
No results are returned by the “finally” branch.
-
class
awssl.ext.
ParallelWithFinally
(Name=None, Comment='', InputPath='$', OutputPath='$', NextState=None, EndState=None, ResultPath='$', RetryList=None, CatcherList=None, FinallyState=None, BranchList=None)¶ Models the
ParallelWithFinally
state, which allows concurrent processing of branches, with the overall state having an optional “finally” branch execution after all branches have completed, or when an error is raised that is caught by aCatcher
.Either:
EndState
isTrue
andNextState
must beNone
EndState
isFalse
andNextState
must be a valid instance of a class derived fromStateBase
.
Output is returned as a
list
of the outputs from each branch.Parameters: - Name (str) – [Required] The name of the state within the branch of the state machine
- Comment (str) – [Optional] A comment describing the intent of this pass state
- InputPath (str) – [Optional] Filter on the Input information to be passed to the Pass state. Default is “$”, signifying that all the Input information will be provided
- OutputPath (str) – [Optional] Filter on the Output information to be returned from the Pass state. Default is “$”, signifying that all the result information will be provided
- EndState (bool) – [Optional] Flag indicating if this state terminates a branch of the state machine. Defaults to
False
- NextState (instance of class derived from
StateBase
) – [Optional] Next state to be invoked within this branch. Must not beNone
unlessEndState
isTrue
- ResultPath (str) – [Optional] JSONPath indicating where results should be added to the Input. Defaults to “$”, indicating results replace the Input entirely.
- RetryList – [Optional]
list
ofRetrier
instances corresponding to error states that cause the entire set of branches to be retried - CatcherList – [Optional]
list
ofCatcher
instances corresponding to error states that can be caught and handled by further states being executed in theStateMachine
. - FinallyState – [Optional] First state of the finally branch to be invoked
- BranchList – [Required]
list
ofStateBase
instances, providing the starting states for each branch to be run concurrently
Type: RetryList: list of
Retrier
Type: CatcherList: list of
Catcher
Type: FinallyState: Derived from
StateBase
Type: BranchList: list of
StateBase
-
add_branch
(StartObject=None)¶ Adds a branch starting at the specified
StartObject
, which must be inherited fromStateBase
.
-
clone
(NameFormatString='{}')¶ Returns a clone of this instance, with the clone named per the NameFormatString, to avoid state name clashes.
If this instance is not an end state, then the next state will also be cloned, to establish a complete clone of the branch form this instance onwards.
Parameters: NameFormatString (str) – [Required] The naming template to be applied to generate the name of the new instance. Returns: ParallelWithFinally
– A new instance of this instance and any other instances in its branch.
-
get_branch_list
()¶ Returns the list of starting states for each branch.
Returns: list of StateBase
-
set_branch_list
(BranchList=None)¶ Sets the list of starting states for each branch to be executed concurrently.
At least one branch is required for the state to be valid.
Parameters: BranchList – [Required] list
ofStateBase
instances, providing the starting states for each branch to be run concurrentlyType: BranchList: list of StateBase