All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.resilience4j.bulkhead.operator.BulkheadSingleObserver Maven / Gradle / Ivy

Go to download

Resilience4j is a lightweight, easy-to-use fault tolerance library designed for Java8 and functional programming

There is a newer version: 2.2.0
Show newest version
package io.github.resilience4j.bulkhead.operator;

import static java.util.Objects.requireNonNull;

import io.github.resilience4j.bulkhead.Bulkhead;
import io.reactivex.SingleObserver;
import io.reactivex.disposables.Disposable;

/**
 * A RxJava {@link SingleObserver} to wrap another observer in a bulkhead.
 *
 * @param  the value type of the upstream and downstream
 */
final class BulkheadSingleObserver extends DisposableBulkhead implements SingleObserver {
    private final SingleObserver childObserver;

    BulkheadSingleObserver(Bulkhead bulkhead, SingleObserver childObserver) {
        super(bulkhead);
        this.childObserver = requireNonNull(childObserver);
    }

    @Override
    public void onSubscribe(Disposable disposable) {
        onSubscribeWithPermit(disposable);
    }

    @Override
    protected void onSubscribeInner(Disposable disposable) {
        childObserver.onSubscribe(disposable);
    }

    @Override
    public void onSuccess(T value) {
        onSuccessInner(value);
    }

    @Override
    protected void permittedOnSuccess(T value) {
        childObserver.onSuccess(value);
    }

    @Override
    public void onError(Throwable e) {
        onErrorInner(e);
    }

    @Override
    protected void permittedOnError(Throwable e) {
        childObserver.onError(e);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy