Java Code Examples for org.eclipse.microprofile.reactive.streams.operators.spi.Stage#OnErrorResumeWith

The following examples show how to use org.eclipse.microprofile.reactive.streams.operators.spi.Stage#OnErrorResumeWith . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OnErrorResumeWithStageFactory.java    From smallrye-mutiny with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.OnErrorResumeWith stage) {
    Function<Throwable, Graph> function = Objects.requireNonNull(stage).getFunction();
    Objects.requireNonNull(function);

    return source -> (Multi<O>) source.onFailure().recoverWithMulti(failure -> {
        Graph graph = function.apply(failure);
        Publisher<I> publisher = engine.buildPublisher(Objects.requireNonNull(graph));
        return Multi.createFrom().publisher(publisher);
    });
}
 
Example 2
Source File: OnErrorResumeWithStageFactory.java    From smallrye-reactive-streams-operators with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <I, O> ProcessingStage<I, O> create(Engine engine, Stage.OnErrorResumeWith stage) {
    Function<Throwable, Graph> function = Objects.requireNonNull(stage).getFunction();
    Objects.requireNonNull(function);

    return source -> (Flowable<O>) RxJavaPlugins.onAssembly(
            new OnErrorResumeWith<>(source, (Throwable err) -> {
                Graph graph = function.apply(err);
                return Flowable.fromPublisher(
                        Objects.requireNonNull(engine.buildPublisher(Objects.requireNonNull(graph))));
            }));
}