io.reactivex.rxjava3.core.SingleObserver Java Examples

The following examples show how to use io.reactivex.rxjava3.core.SingleObserver. 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: SingleCircuitBreaker.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Override
protected void subscribeActual(SingleObserver<? super T> downstream) {
    if (circuitBreaker.tryAcquirePermission()) {
        upstream.subscribe(new CircuitBreakerSingleObserver(downstream));
    } else {
        downstream.onSubscribe(EmptyDisposable.INSTANCE);
        downstream.onError(createCallNotPermittedException(circuitBreaker));
    }
}
 
Example #2
Source File: SingleBulkhead.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Override
protected void subscribeActual(SingleObserver<? super T> downstream) {
    if (bulkhead.tryAcquirePermission()) {
        upstream.subscribe(new BulkheadSingleObserver(downstream));
    } else {
        downstream.onSubscribe(EmptyDisposable.INSTANCE);
        downstream.onError(BulkheadFullException.createBulkheadFullException(bulkhead));
    }
}
 
Example #3
Source File: SingleRateLimiter.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Override
protected void subscribeActual(SingleObserver<? super T> downstream) {
    long waitDuration = rateLimiter.reservePermission();
    if (waitDuration >= 0) {
        if (waitDuration > 0) {
            Completable.timer(waitDuration, TimeUnit.NANOSECONDS)
                .subscribe(() -> upstream.subscribe(new RateLimiterSingleObserver(downstream)));
        } else {
            upstream.subscribe(new RateLimiterSingleObserver(downstream));
        }
    } else {
        downstream.onSubscribe(EmptyDisposable.INSTANCE);
        downstream.onError(RequestNotPermitted.createRequestNotPermitted(rateLimiter));
    }
}
 
Example #4
Source File: SingleCircuitBreaker.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
CircuitBreakerSingleObserver(SingleObserver<? super T> downstreamObserver) {
    super(downstreamObserver);
    this.start = System.nanoTime();
}
 
Example #5
Source File: SingleBulkhead.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
BulkheadSingleObserver(SingleObserver<? super T> downstreamObserver) {
    super(downstreamObserver);
}
 
Example #6
Source File: AbstractSingleObserver.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
public AbstractSingleObserver(SingleObserver<? super T> downstreamObserver) {
    this.downstreamObserver = requireNonNull(downstreamObserver);
}
 
Example #7
Source File: SingleRateLimiter.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
RateLimiterSingleObserver(SingleObserver<? super T> downstreamObserver) {
    super(downstreamObserver);
}
 
Example #8
Source File: RequestContextSingleObserver.java    From armeria with Apache License 2.0 4 votes vote down vote up
RequestContextSingleObserver(SingleObserver<T> actual, RequestContext assemblyContext) {
    this.actual = actual;
    this.assemblyContext = assemblyContext;
}
 
Example #9
Source File: RequestContextSupplierSingle.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
protected void subscribeActual(SingleObserver<? super T> s) {
    try (SafeCloseable ignored = assemblyContext.push()) {
        source.subscribe(new RequestContextSingleObserver<>(s, assemblyContext));
    }
}
 
Example #10
Source File: RequestContextScalarSupplierSingle.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
protected void subscribeActual(SingleObserver<? super T> s) {
    try (SafeCloseable ignored = assemblyContext.push()) {
        source.subscribe(new RequestContextSingleObserver<>(s, assemblyContext));
    }
}
 
Example #11
Source File: RequestContextSingle.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
protected void subscribeActual(SingleObserver<? super T> s) {
    try (SafeCloseable ignored = assemblyContext.push()) {
        source.subscribe(new RequestContextSingleObserver<>(s, assemblyContext));
    }
}