-
Notifications
You must be signed in to change notification settings - Fork 44
Retry
Lucas Nelaupe edited this page Jan 12, 2018
·
3 revisions
Jobs will only be retried by default, you will have to specify a retry count in JobBuilder
.
.retry(limit: .limited(5)) // Limit to 5 retry
.retry(limit: .unlimited) // Retry until cancel
SwiftQueue
will invoke your implementation of onRetry
with the current error encountered. If the error is due to a constraint like DeadlineError
or TaskAlreadyExist
. onError
will NOT be called since there is no way for you to retry.
func onRetry(error: Error) -> RetryConstraint {
if error is RetryAble {
// Retry after a certain delay in Seconds
return RetryConstraint.delay(0)
// You can also specify an exponential back-off
return RetryConstraint.exponential(initial: 1)
} else {
// No retry, onRemoved will be called
return RetryConstraint.cancel
}
}