-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RestartSource.onFailuresWithBackoff should support failing on (custom) fatal errors #30859
Comments
Sounds like it a "decider" would be a useful addition to both those operators. Should probably go in the |
Yes, that makes sense. An additional overload would indeed make it quite hard to read/use. The implementation of this in |
But looking at it with fresh eyes, would it be correct to say that if we can get a "decider" down to the So something like this: override def onUpstreamFailure(ex: Throwable) = {
if (finishing || maxRestartsReached() || decider.alwaysFailOn(ex)) {
fail(out, ex)
} else {
logIt(s"Restarting stream due to failure [${restartCount + 1}]: $ex", OptionVal.Some(ex))
scheduleRestartTimer()
}
} If that is the only code that would have to change than I could work on an initial PR for that. |
Sounds about right, looks like there is corresponding in both the out handler and the in handler, so probably at least both those places would need to invoke a decider. |
OK. I think it would be better to create a new |
I agree, perhaps even a simple lambda returning boolean rather than encoding the return value as an ADT, something like |
You can work around this somewhat by wrapping the stream elements in a RestartSource.onFailuresWithBackoff(restartSettings) { () =>
Source(...).map(Success(_)).recover {
case ex: InvalidOAuthTokenException => Failure(ex)
}
}.map(_.get) |
I have several use cases that generally run as follows:
In such special error cases the stream should clearly be stopped since it is no use to continue, e.g. we have encountered a fatal error scenario that needs to be handled with some other behavior than mindless restarting the stream.
We currently solve this issue using custom graph stages because, as far as we can work out, there is no version of
RestartSource
(orRestartFlow
) that supports retrying only on some errors but failing on others.It would be great if the various
.onFailuresWithBackoff
methods (or a new method) would support some way to express which errors should be retried and which ones should lead to failure.The text was updated successfully, but these errors were encountered: