Retries
Using retries it is possible to define fault-tolerant automations.
Use Cases
Use retries
- When certain parts of your automation occasionally fail and the failure is temporary.
- To poll a system until it reaches a certain status.
Concept
The retry feature is implemented as a Wrapper.
Importing the Wrapper bundle will provide you with a wrapper called retry
.
When the retry
wrapper is attached to a connector, it will monitor the execution status of the connection and restart the execution in case an error occurs.
As all wrappers, the retry
wrapper can be statically attached and configured. Please refer to Static Wrappers for more information.
Alternatively, the retry
wrapper can be dynamically attached and configured. Please refer to Dynamic Wrappers for more information.
The most common usage is to dynamically attach and configure the retry
wrapper to a connector. This way the configuration of the retries is individual to the particular use of the connector.
The retry
wrapper provided by Cloudomation is considered an example which can be extended or modified to your needs.
Parameters
The retry
wrapper accepts the following parameters:
Name | Type | Description | Required | Default value |
---|---|---|---|---|
max_tries | int | Maximum number of tries before failing. | no | 3 |
delay_sec | int | Number of seconds to wait between tries. | no | 10 |
timeout_sec | int | A timeout across all tries. Specify 0 to disable the timeout. | no | 0 |
Examples
Using a connection with retries
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
# We want to try to connect to <name-of-a-connector>.
# There are a maximum of 10 attempts. If an attempt fails,
# we'll wait 30 seconds until retrying.
this.using(
'retry',
max_tries=10,
delay_sec=30,
).connect('<name-of-a-connector>')
return this.success('all done')