2018-10-15 18:11:33 +02:00
|
|
|
# RestartSink.withBackoff
|
|
|
|
|
|
2019-04-03 13:14:27 +02:00
|
|
|
Wrap the given @apidoc[Sink] with a @apidoc[Sink] that will restart it when it fails or complete using an exponential backoff.
|
2018-10-15 18:11:33 +02:00
|
|
|
|
|
|
|
|
@ref[Error handling](../index.md#error-handling)
|
|
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
|
2020-04-30 08:59:22 +02:00
|
|
|
@apidoc[RestartSink.withBackoff](RestartSink$) { scala="#withBackoff[T](minBackoff:scala.concurrent.duration.FiniteDuration,maxBackoff:scala.concurrent.duration.FiniteDuration,randomFactor:Double,maxRestarts:Int)(sinkFactory:()=>akka.stream.scaladsl.Sink[T,_]):akka.stream.scaladsl.Sink[T,akka.NotUsed]" java="#withBackoff(java.time.Duration,java.time.Duration,double,int,akka.japi.function.Creator)" }
|
2018-10-15 18:11:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
|
2019-04-03 13:14:27 +02:00
|
|
|
This @apidoc[Sink] will never cancel, since cancellation by the wrapped @apidoc[Sink] is always handled by restarting it.
|
|
|
|
|
The wrapped @apidoc[Sink] can however be completed by feeding a completion or error into this @apidoc[Sink]. When that
|
|
|
|
|
happens, the @apidoc[Sink], if currently running, will terminate and will not be restarted. This can be triggered
|
|
|
|
|
simply by the upstream completing, or externally by introducing a @apidoc[KillSwitch] right before this @apidoc[Sink] in the
|
2018-10-15 18:11:33 +02:00
|
|
|
graph.
|
|
|
|
|
|
|
|
|
|
The restart process is inherently lossy, since there is no coordination between cancelling and the sending of
|
2019-04-03 13:14:27 +02:00
|
|
|
messages. When the wrapped @apidoc[Sink] does cancel, this @apidoc[Sink] will backpressure, however any elements already
|
2018-10-15 18:11:33 +02:00
|
|
|
sent may have been lost.
|
|
|
|
|
|
2020-06-26 09:07:01 +02:00
|
|
|
This uses the same exponential backoff algorithm as @apidoc[Backoff$].
|