Polling instructs the client to periodically make an HTTP GET request to the specified URL and eventually trigger an action.
Polling is typically used alongside External. For example, a step may first open an external URL and then poll for a server state change. The client may continue to another step or end the flow.
Given the step below, the client will start making requests to the specified URL every 5 seconds.
To continue polling, the response should have a 2xx status code and an empty body. The client will continue to make requests until the flow progresses or [maxAttempts] is reached.
To stop polling, the response should be a Flow Response with the X-DF-Response-Type header set accordingly. Note that older clients only support Action Response Body
Step.build {
layout { }
polling {
url = "https://bar.foo/status?id=12345"
delay = 5
timeout = 60
maxAttempts = 100
onError {
behavior = ActionBehavior.build {
action {
exit = true
result = encodeToJsonElement(mapOf("exit-action-data" to "EXIT!!!"))
}
}
}
}
}
Given the above step, the behaviour in the onError object is triggered if:
- the response status code is a failure (>=400).
- the number of attempts exceeds the specified
maxAttempts - the response body does not match the
X-DF-Response-Typeheader provided
| Property | Type | Required | Description |
|---|---|---|---|
| Int | Yes | The time in seconds between receiving a response and executing the next request.
|
interval | Int | No | |
maxAttempts | Int | Yes | The maximum number of requests that may be attempted, before triggering the [onError] action. |
onError | Polling.OnError | Yes | An object with one action property to be triggered when polling fails. |
| Int | No | The suggested request timeout in seconds. Typically used when an endpoint is expected to take a long time to respond.
|
url | String | Yes | The URL to open. |
| Property | Type | Required | Description |
|---|---|---|---|
| No | The Action to be triggered when polling fails. ⚠️ Deprecated - Please use | |
| Yes | The Behavior to be triggered when polling fails.
|