Polling for Async Steps
Many API workflows involve asynchronous operations where you submit a request and then poll a status endpoint until the operation completes. ReṼoman has built-in polling support through pollingConfig(), eliminating fragile Thread.sleep() workarounds in Post-Step Hooks.
Configuration
Configure polling using the PollingConfig builder DSL and pass it to the Kick config:
Kick.configure()
.templatePath(PM_COLLECTION_PATH)
.pollingConfig(
PollingConfig.poll(afterStepName("submit-async-job")) (1)
.request((stepReport, env) -> (2)
Request.create(Method.GET, env.get("statusUrl").toString()))
.every(Duration.ofSeconds(5)) (3)
.timeout(Duration.ofSeconds(60)) (4)
.until((response, env) -> (5)
response.bodyString().contains("\"status\":\"COMPLETED\"")))
.off();
| 1 | poll() accepts a PostTxnStepPick predicate to select which step triggers polling |
| 2 | request() builds the HTTP request for each poll attempt, using the step’s report and current environment |
| 3 | every() sets the interval between poll attempts (default: 2 seconds) |
| 4 | timeout() sets the maximum duration before giving up (default: 30 seconds) |
| 5 | until() is the terminal operation — the PollingCompletionPredicate receives each poll response and returns true when the async operation is complete |
How it works
After a step completes successfully and matches the PostTxnStepPick, ReṼoman:
-
Builds and fires the poll request using the configured
PollingRequestBuilder -
Evaluates the response with the
PollingCompletionPredicate -
If
true, records aPollingReport(with attempt count, total duration, and all responses) in theStepReport -
If
false, waits for the configured interval and retries -
If the timeout elapses without completion, reports a
PollingTimeoutFailure -
If the request builder or HTTP call throws, reports a
PollingRequestFailure
Polling Report
On success, StepReport.pollingReport contains:
* pollAttempts — number of attempts until completion
* totalDuration — wall-clock time spent polling
* responses — all HTTP responses collected during polling
Failure handling
Polling failures are captured in StepReport.pollingFailure and follow the same Failure Hierarchy as other failures:
* PollingTimeoutFailure — polling exceeded the configured timeout
* PollingRequestFailure — the request builder or HTTP call threw an exception
If the PollingCompletionPredicate throws an exception, it is treated as returning false (i.e., not yet complete), and polling continues.
|