withFallbacks method
RunnableWithFallback<RunInput, RunOutput>
withFallbacks(
- List<
Runnable< fallbacksRunInput, RunnableOptions, RunOutput> >
Adds fallback runnables to be invoked if the primary runnable fails.
This method creates a RunnableWithFallback instance that wraps the
current Runnable. If the initial invocation of the current Runnable
fails, the fallbacks
runnables are attempted in the order they are
provided. This process continues until a runnable succeeds or all
fallbacks fail. The result of the first successful runnable is returned,
or an error is thrown if all runnables fail.
fallbacks
- A list of Runnable instances to be used as fallbacks.
Implementation
RunnableWithFallback<RunInput, RunOutput> withFallbacks(
List<Runnable<RunInput, RunnableOptions, RunOutput>> fallbacks,
) {
return RunnableWithFallback<RunInput, RunOutput>(
mainRunnable: this,
fallbacks: fallbacks,
);
}