Class RestartSource
- java.lang.Object
-
- akka.stream.scaladsl.RestartSource
-
public class RestartSource extends java.lang.ObjectWrap the givenSourcewith aSourcethat will restart it when it fails or complete using an exponential backoff.This
Sourcewill never emit a complete or failure, since the completion or failure of the wrappedSourceis always handled by restarting it. The wrappedSourcecan however be cancelled by cancelling thisSource. When that happens, the wrappedSource, if currently running will be cancelled, and it will not be restarted. This can be triggered simply by the downstream cancelling, or externally by introducing aKillSwitchright after thisSourcein the graph.This uses the same exponential backoff algorithm as
Backoff.param: minBackoff minimum (initial) duration until the child actor will started again, if it is terminated param: maxBackoff the exponential back-off is capped to this duration param: randomFactor after calculation of the exponential back-off an additional random delay based on this factor is added, e.g.
0.2adds up to20%delay. In order to skip this additional delay pass in0. param: sourceFactory A factory for producing theSourceto wrap.
-
-
Constructor Summary
Constructors Constructor Description RestartSource()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Source<T,NotUsed>onFailuresWithBackoff(scala.concurrent.duration.FiniteDuration minBackoff, scala.concurrent.duration.FiniteDuration maxBackoff, double randomFactor, int maxRestarts, scala.Function0<Source<T,?>> sourceFactory)static <T> Source<T,NotUsed>onFailuresWithBackoff(scala.concurrent.duration.FiniteDuration minBackoff, scala.concurrent.duration.FiniteDuration maxBackoff, double randomFactor, scala.Function0<Source<T,?>> sourceFactory)static <T> Source<T,NotUsed>withBackoff(scala.concurrent.duration.FiniteDuration minBackoff, scala.concurrent.duration.FiniteDuration maxBackoff, double randomFactor, int maxRestarts, scala.Function0<Source<T,?>> sourceFactory)static <T> Source<T,NotUsed>withBackoff(scala.concurrent.duration.FiniteDuration minBackoff, scala.concurrent.duration.FiniteDuration maxBackoff, double randomFactor, scala.Function0<Source<T,?>> sourceFactory)
-
-
-
Method Detail
-
withBackoff
public static <T> Source<T,NotUsed> withBackoff(scala.concurrent.duration.FiniteDuration minBackoff, scala.concurrent.duration.FiniteDuration maxBackoff, double randomFactor, scala.Function0<Source<T,?>> sourceFactory)
-
withBackoff
public static <T> Source<T,NotUsed> withBackoff(scala.concurrent.duration.FiniteDuration minBackoff, scala.concurrent.duration.FiniteDuration maxBackoff, double randomFactor, int maxRestarts, scala.Function0<Source<T,?>> sourceFactory)
Wrap the givenSourcewith aSourcethat will restart it when it fails or complete using an exponential backoff.This
Sourcewill not emit a complete or failure as long as maxRestarts is not reached, since the completion or failure of the wrappedSourceis handled by restarting it. The wrappedSourcecan however be cancelled by cancelling thisSource. When that happens, the wrappedSource, if currently running will be cancelled, and it will not be restarted. This can be triggered simply by the downstream cancelling, or externally by introducing aKillSwitchright after thisSourcein the graph.This uses the same exponential backoff algorithm as
Backoff.- Parameters:
minBackoff- minimum (initial) duration until the child actor will started again, if it is terminatedmaxBackoff- the exponential back-off is capped to this durationrandomFactor- after calculation of the exponential back-off an additional random delay based on this factor is added, e.g.0.2adds up to20%delay. In order to skip this additional delay pass in0.maxRestarts- the amount of restarts is capped to this amount within a time frame of minBackoff. Passing0will cause no restarts and a negative number will not cap the amount of restarts.sourceFactory- A factory for producing theSourceto wrap.- Returns:
- (undocumented)
-
onFailuresWithBackoff
public static <T> Source<T,NotUsed> onFailuresWithBackoff(scala.concurrent.duration.FiniteDuration minBackoff, scala.concurrent.duration.FiniteDuration maxBackoff, double randomFactor, scala.Function0<Source<T,?>> sourceFactory)
Wrap the givenSourcewith aSourcethat will restart it when it fails using an exponential backoff.This
Sourcewill never emit a failure, since the failure of the wrappedSourceis always handled by restarting. The wrappedSourcecan be cancelled by cancelling thisSource. When that happens, the wrappedSource, if currently running will be cancelled, and it will not be restarted. This can be triggered simply by the downstream cancelling, or externally by introducing aKillSwitchright after thisSourcein the graph.This uses the same exponential backoff algorithm as
Backoff.- Parameters:
minBackoff- minimum (initial) duration until the child actor will started again, if it is terminatedmaxBackoff- the exponential back-off is capped to this durationrandomFactor- after calculation of the exponential back-off an additional random delay based on this factor is added, e.g.0.2adds up to20%delay. In order to skip this additional delay pass in0.sourceFactory- A factory for producing theSourceto wrap.- Returns:
- (undocumented)
-
onFailuresWithBackoff
public static <T> Source<T,NotUsed> onFailuresWithBackoff(scala.concurrent.duration.FiniteDuration minBackoff, scala.concurrent.duration.FiniteDuration maxBackoff, double randomFactor, int maxRestarts, scala.Function0<Source<T,?>> sourceFactory)
Wrap the givenSourcewith aSourcethat will restart it when it fails using an exponential backoff.This
Sourcewill not emit a complete or failure as long as maxRestarts is not reached, since the completion or failure of the wrappedSourceis handled by restarting it. The wrappedSourcecan however be cancelled by cancelling thisSource. When that happens, the wrappedSource, if currently running will be cancelled, and it will not be restarted. This can be triggered simply by the downstream cancelling, or externally by introducing aKillSwitchright after thisSourcein the graph.This uses the same exponential backoff algorithm as
Backoff.- Parameters:
minBackoff- minimum (initial) duration until the child actor will started again, if it is terminatedmaxBackoff- the exponential back-off is capped to this durationrandomFactor- after calculation of the exponential back-off an additional random delay based on this factor is added, e.g.0.2adds up to20%delay. In order to skip this additional delay pass in0.maxRestarts- the amount of restarts is capped to this amount within a time frame of minBackoff. Passing0will cause no restarts and a negative number will not cap the amount of restarts.sourceFactory- A factory for producing theSourceto wrap.- Returns:
- (undocumented)
-
-