Package akka.pattern

Interface RetrySupport

  • All Known Implementing Classes:
    RetrySupport$

    public interface RetrySupport
    Given a function from Unit to Future, returns an internally retrying Future The first attempt will be made immediately, each subsequent attempt will be made after 'delay' A scheduler (eg context.system.scheduler) must be provided to delay each retry If attempts are exhausted the returned future is simply the result of invoking attempt. Note that the attempt function will be invoked on the given execution context for subsequent tries and therefore must be thread safe (not touch unsafe mutable state).

    Example usage:

    
     protected val sendAndReceive: HttpRequest => Future[HttpResponse]
     private val sendReceiveRetry: HttpRequest => Future[HttpResponse] = (req: HttpRequest) => retry[HttpResponse](
       attempt = () => sendAndReceive(req),
       attempts = 10,
       delay = 2 seconds,
       scheduler = context.system.scheduler
     )
     
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T> scala.concurrent.Future<T> retry​(scala.Function0<scala.concurrent.Future<T>> attempt, int attempts, scala.concurrent.duration.FiniteDuration delay, scala.concurrent.ExecutionContext ec, Scheduler scheduler)
      Given a function from Unit to Future, returns an internally retrying Future The first attempt will be made immediately, each subsequent attempt will be made after 'delay' A scheduler (eg context.system.scheduler) must be provided to delay each retry If attempts are exhausted the returned future is simply the result of invoking attempt.
    • Method Detail

      • retry

        <T> scala.concurrent.Future<T> retry​(scala.Function0<scala.concurrent.Future<T>> attempt,
                                             int attempts,
                                             scala.concurrent.duration.FiniteDuration delay,
                                             scala.concurrent.ExecutionContext ec,
                                             Scheduler scheduler)
        Given a function from Unit to Future, returns an internally retrying Future The first attempt will be made immediately, each subsequent attempt will be made after 'delay' A scheduler (eg context.system.scheduler) must be provided to delay each retry If attempts are exhausted the returned future is simply the result of invoking attempt. Note that the attempt function will be invoked on the given execution context for subsequent tries and therefore must be thread safe (not touch unsafe mutable state).

        Example usage:

        
         protected val sendAndReceive: HttpRequest => Future[HttpResponse]
         private val sendReceiveRetry: HttpRequest => Future[HttpResponse] = (req: HttpRequest) => retry[HttpResponse](
           attempt = () => sendAndReceive(req),
           attempts = 10,
           delay = 2 seconds,
           scheduler = context.system.scheduler
         )
         
        Parameters:
        attempt - (undocumented)
        attempts - (undocumented)
        delay - (undocumented)
        ec - (undocumented)
        scheduler - (undocumented)
        Returns:
        (undocumented)