Retry
Says how often a node is tried again after it failed, and how long the engine waits between two tries. Give it to a node as retry:
val fetch = node("fetch", retry = Retry(attempts = 3)) { order ->
order.copy(stock = warehouse.stock(order.item))
}A node that fails runs again on the same state, in the same step, until it succeeds or has run attempts times. Then the run fails with a NodeExecutionException, as it does without a retry. The engine waits pause before the second try, and factor times longer before each try after it, but never longer than maxPause: with the defaults 1 second, then 2, then 4.
Every failure of the node is retried, also a time limit of the node that ran out, with one exception: a GraphValidationException is not, because a second try would fail in the same way. To retry only some failures, pass retryOn:
Retry(attempts = 3) { failure -> failure is IOException }What is no failure of a node is never retried: a cancelled run, a pause with interrupt, and an error of the program such as an AssertionError.
A node with a retry runs more than once, so make its side effects safe to repeat.