本文介绍等待状态及其相关使用示例。
基本概念
等待状态可以将执行流程暂停一段时间,然后再继续执行。您可以选择一个相对时间,也可以以时间戳方式指定一个绝对结束时间,甚至可以使用表达式从上下文中获取一个时间。
等待状态包含以下属性。
字段 | 类型 | 是否必选 | 描述 | 示例值 |
Seconds | int | 否 | 等待的时间。单位为秒。与UntilDateTime互斥,优先级较高。 | 30 |
UntilDateTime | string | 否 | 开始执行的时间。与Seconds互斥,优先级较Seconds低。 | 2023-10-02T15:04:05Z或者$Input.timeField |
Name | string | 是 | 状态名称。 | my state |
Description | string | 否 | 状态描述。 | describe it here |
Type | string | 是 | 状态类型。 | Pass |
Next | string | 否 | 当前状态的下一个状态。当End取值为true时,无需指定。 | my next |
End | bool | 否 | 是否为当前作用域的终结节点。 | true |
InputConstructor | map[string]any | 否 | 输入构造器。 | 请参见输入构造器 |
OutputConstructor | map[string]any | 否 | 输出构造器。 | 请参见输出构造器 |
其中UntilDateTime为等待的绝对时间,格式为RFC3339,可以是常量,例如2023-10-02T15:04:05Z
,也可以是输入中的某个参数,例如$Input.timeField
。
UntilDateTime取值为常量2023-10-02T15:04:05Z
,表示等待到UTC时间的2023年10月02日15点04分05秒。如果该时间早于当前时间,则等待状态直接结束。
使用示例
等待30秒
Type: StateMachine Name: my-wkfl SpecVersion: v1 StartAt: Wait1 States: - Type: Wait Name: Wait1 Seconds: 30 End: true
等待到绝对时间
Type: StateMachine Name: my-wkfl SpecVersion: v1 StartAt: Wait1 States: - Type: Wait Name: Wait1 UntilDateTime: 2023-10-02T15:04:05Z End: true
等待绝对时间由输入决定
Type: StateMachine Name: my-wkfl SpecVersion: v1 StartAt: Wait1 States: - Type: Wait Name: Wait1 UntilDateTime: $Input.timeField End: true
反馈
- 本页导读 (1)
文档反馈