BackoffRetryStrategy

open class BackoffRetryStrategy: JobRetryStrategy

Will retry the job every N seconds, scaling at a power of 2, until a max number of seconds is reached, at which point the queue will try to re-process the job at that max time interval.

MaxRetryStrategy is appropriate for situations wherein failure may decrease over time. A good example would be a Processor which is attempting to upload data to a server, but the server is down. We don’t want to continuously ping the server, rather we want to gradually back off more and more over time until the server is back online.

  • Initializes this strategy for a given job and the max number of attempts

    Declaration

    Swift

    public convenience init(maxBackoff: TimeInterval)

    Parameters

    handling

    The type of job this strategy is handling

    maxAttempts

    The maximum number of times a job should be attempted to be processed, including the initial attempt to process. If, for example, maxAttempts is 5, then a job will be retried a maximum number of 4 times.

  • Retries the job. If the maximum number of attempts has been reached for the job then the job will not be retried and will be purged from the queue.

    Declaration

    Swift

    public func retry<JobType: QueueJob>(job: JobType, failedOnQueue queue: JobQueue<JobType>)

    Parameters

    job

    The job that failed

    queue

    The queue on which the job failed