This topic describes Wait states and provides related examples.
Overview
A Wait state is used to pause a flow execution for a period of time and then resume the execution. You can set the waiting time to a duration, use a timestamp to specify an absolute end time, or use an expression to obtain the end time from the context.
The following table describes the attributes that a Wait state contains.
Attribute | Type | Required | Description | Example |
Seconds | int | No | The waiting time. Unit: seconds. This attribute is mutually exclusive with the UntilDateTime attribute and has a higher priority than the UntilDateTime attribute. | 30 |
UntilDateTime | string | No | The time when the flow execution resumes. This attribute is mutually exclusive with the Seconds attribute and has a lower priority than the Seconds attribute. | 2023-10-02T15:04:05Z, $Input.timeField |
Name | string | Yes | The name of the state. | my state |
Description | string | No | The description of the state. | describe it here |
Type | string | Yes | The type of the state. | Pass |
Next | string | No | The next state that is executed after the current state is complete. If the End attribute is true, you do not need to specify this attribute. | my next |
End | bool | No | Specifies whether to end the current scope. | true |
InputConstructor | map[string]any | No | The input constructor. | See InputConstructor. |
OutputConstructor | map[string]any | No | The output constructor. | See OutputConstructor. |
The UntilDateTime attribute specifies the absolute time to wait until. The time follows the RFC3339 standard. The time can be a constant. Example: 2023-10-02T15:04:05Z
. The time can also be a parameter in the input. Example: $Input.timeField
.
For example, if you set the UntilDateTime attribute to 2023-10-02T15:04:05Z
, the flow waits until 15:04:05 on October 2, 2023 and then resumes. The time must be in UTC. If the specified time is earlier than the current time, the Wait state directly ends.
Examples
Wait 30 seconds.
Type: StateMachine Name: my-wkfl SpecVersion: v1 StartAt: Wait1 States: - Type: Wait Name: Wait1 Seconds: 30 End: true
Wait until the absolute end time arrives.
Type: StateMachine Name: my-wkfl SpecVersion: v1 StartAt: Wait1 States: - Type: Wait Name: Wait1 UntilDateTime: 2023-10-02T15:04:05Z End: true
Wait a period that is determined by the input.
Type: StateMachine Name: my-wkfl SpecVersion: v1 StartAt: Wait1 States: - Type: Wait Name: Wait1 UntilDateTime: $Input.timeField End: true