RestartFlow.withBackoff

Wrap the given FlowFlow with a FlowFlow that will restart it when it fails or complete using an exponential backoff.

Error handling

Signature

def withBackoff[In, Out](minBackoff: FiniteDuration, maxBackoff: FiniteDuration, randomFactor: Double)(flowFactory: () ⇒ Flow[In, Out, _]): Flow[In, Out, NotUsed]
def withBackoff[In, Out](minBackoff: FiniteDuration, maxBackoff: FiniteDuration, randomFactor: Double, maxRestarts: Int)(flowFactory: () ⇒ Flow[In, Out, _]): Flow[In, Out, NotUsed]

Description

The resulting FlowFlow will not cancel, complete or emit a failure, until the opposite end of it has been cancelled or completed. Any termination by the FlowFlow before that time will be handled by restarting it. Any termination signals sent to this FlowFlow however will terminate the wrapped FlowFlow, if it’s running, and then the FlowFlow will be allowed to terminate without being restarted.

The restart process is inherently lossy, since there is no coordination between cancelling and the sending of messages. A termination signal from either end of the wrapped FlowFlow will cause the other end to be terminated, and any in transit messages will be lost. During backoff, this FlowFlow will backpressure.

This uses the same exponential backoff algorithm as BackoffBackoff.

Reactive Streams semantics

emits when the wrapped flow emits

backpressures during backoff and when the wrapped flow backpressures

completes when the wrapped flow completes

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.