RestartSource.withBackoff
Wrap the given Source
Source
with a Source
Source
that will restart it when it fails or complete using an exponential backoff.
Signature
def withBackoff[T](minBackoff: FiniteDuration, maxBackoff: FiniteDuration, randomFactor: Double)(sourceFactory: () => Source[T, _]): Source[T, NotUsed]
def withBackoff[T](minBackoff: FiniteDuration, maxBackoff: FiniteDuration, randomFactor: Double, maxRestarts: Int)(sourceFactory: () => Source[T, _]): Source[T, NotUsed]
Description
This Flow
Flow
will never emit a complete or failure, since the completion or failure of the wrapped Source
Source
is always handled by restarting it. The wrapped Source
Source
can however be cancelled by cancelling this Source
Source
. When that happens, the wrapped Source
Source
, 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 a KillSwitch
KillSwitch
right after this Source
Source
in the graph.
This uses the same exponential backoff algorithm as Backoff
.
Reactive Streams semantics
emits when the wrapped source emits
completes when the wrapped source completes