io.github.resilience4j.ratelimiter.operator.RateLimiterCompletableObserver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of resilience4j-rxjava2 Show documentation
Show all versions of resilience4j-rxjava2 Show documentation
Resilience4j is a lightweight, easy-to-use fault tolerance library designed for Java8 and functional programming
package io.github.resilience4j.ratelimiter.operator;
import io.github.resilience4j.ratelimiter.RateLimiter;
import io.reactivex.CompletableObserver;
import io.reactivex.disposables.Disposable;
/**
* A RxJava {@link CompletableObserver} to protect another observer by a {@link RateLimiter}.
* Consumes one permit when subscribed.
*/
final class RateLimiterCompletableObserver extends DisposableRateLimiter implements CompletableObserver {
private final CompletableObserver childObserver;
RateLimiterCompletableObserver(RateLimiter rateLimiter, CompletableObserver childObserver) {
super(rateLimiter);
this.childObserver = childObserver;
}
@Override
public void onSubscribe(Disposable disposable) {
onSubscribeWithPermit(disposable);
}
@Override
protected void onSubscribeInner(Disposable disposable) {
childObserver.onSubscribe(disposable);
}
@Override
public void onComplete() {
onCompleteInner();
}
@Override
protected void permittedOnComplete() {
childObserver.onComplete();
}
@Override
public void onError(Throwable e) {
onErrorInner(e);
}
@Override
protected void permittedOnError(Throwable e) {
childObserver.onError(e);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy