Add retries to a task, based on a list of retry policies, until any one of the policies fail too.
Stop retrying originalTask after a number of retries.
Retry.with [ Retry.maxRetries 20 ] originalTask
|> Task.attempt DidOriginalTaskNOTE: The code above does NOT sleep between retries; best to combine with
constantInterval or exponentialBackoff
Stop retrying originalTask after some number of milliseconds.
Retry.with [ Retry.maxDuration 7000 ] originalTask
|> Task.attempt DidOriginalTaskNOTE: The code above does NOT sleep between retries; best to combine with
constantInterval or exponentialBackoff
Sleep for the same number of milliseconds before every retry.
Retry.with [ Retry.constantInterval 1000 ] originalTask
|> Task.attempt DidOriginalTaskNOTE: The code above will keep retrying originalTask; best to combine with
maxRetries or maxDuration
Sleep for an increasing number of milliseconds before every retry. Backoff algorithim is based off https://github.com/cenkalti/backoff
Retry.with [ Retry.exponentialBackoff { interval = 500, maxInterval = 3000 } ] originalTask
|> Task.attempt DidOriginalTaskNOTE: The code above will keep retrying originalTask; best to combine with
maxRetries or maxDuration
A
Policyis attached with a function that will return anotherPolicyas aTaskvalue.The arguments of the function are
Inttimestamp of when we first startedoriginalTask, in millisecondsPolicy xthe current policy; destructure to obtain the function to callxlast error from attemptingoriginalTaskRefer to
maxRetriessource code for a simple example.