io.reactivex.rxjava3.core.CompletableObserver Java Examples

The following examples show how to use io.reactivex.rxjava3.core.CompletableObserver. 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: CompletableRateLimiter.java    From resilience4j with Apache License 2.0 6 votes vote down vote up
@Override
protected void subscribeActual(CompletableObserver downstream) {
    long waitDuration = rateLimiter.reservePermission();
    if (waitDuration >= 0) {
        if (waitDuration > 0) {
            Completable.timer(waitDuration, TimeUnit.NANOSECONDS)
                .subscribe(
                    () -> upstream.subscribe(new RateLimiterCompletableObserver(downstream)));
        } else {
            upstream.subscribe(new RateLimiterCompletableObserver(downstream));
        }
    } else {
        downstream.onSubscribe(EmptyDisposable.INSTANCE);
        downstream.onError(RequestNotPermitted.createRequestNotPermitted(rateLimiter));
    }
}
 
Example #2
Source File: CompletableCircuitBreaker.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Override
protected void subscribeActual(CompletableObserver downstream) {
    if (circuitBreaker.tryAcquirePermission()) {
        upstream.subscribe(new CircuitBreakerCompletableObserver(downstream));
    } else {
        downstream.onSubscribe(EmptyDisposable.INSTANCE);
        downstream.onError(createCallNotPermittedException(circuitBreaker));
    }
}
 
Example #3
Source File: CompletableBulkhead.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Override
protected void subscribeActual(CompletableObserver downstream) {
    if (bulkhead.tryAcquirePermission()) {
        upstream.subscribe(new BulkheadCompletableObserver(downstream));
    } else {
        downstream.onSubscribe(EmptyDisposable.INSTANCE);
        downstream.onError(BulkheadFullException.createBulkheadFullException(bulkhead));
    }
}
 
Example #4
Source File: CompletableDataItem.java    From java-11-examples with Apache License 2.0 4 votes vote down vote up
@Override
protected void subscribeActual(CompletableObserver observer) {
    executor.execute(new CompletableDataItemTask(dataQuery, observer));
}
 
Example #5
Source File: CompletableDataItemTask.java    From java-11-examples with Apache License 2.0 4 votes vote down vote up
public CompletableDataItemTask(SingleDataQuery dataQuery, CompletableObserver observer) {
    this.dataQuery = dataQuery;
    this.observer = observer;
}
 
Example #6
Source File: CompletableCircuitBreaker.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
CircuitBreakerCompletableObserver(CompletableObserver downstreamObserver) {
    super(downstreamObserver);
    this.start = System.nanoTime();
}
 
Example #7
Source File: CompletableBulkhead.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
BulkheadCompletableObserver(CompletableObserver downstreamObserver) {
    super(downstreamObserver);
}
 
Example #8
Source File: AbstractCompletableObserver.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
public AbstractCompletableObserver(CompletableObserver downstreamObserver) {
    this.downstreamObserver = requireNonNull(downstreamObserver);
}
 
Example #9
Source File: CompletableRateLimiter.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
RateLimiterCompletableObserver(CompletableObserver downstreamObserver) {
    super(downstreamObserver);
}
 
Example #10
Source File: RequestContextCompletable.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
protected void subscribeActual(CompletableObserver s) {
    try (SafeCloseable ignored = assemblyContext.push()) {
        source.subscribe(new RequestContextCompletableObserver(s, assemblyContext));
    }
}
 
Example #11
Source File: RequestContextCompletableObserver.java    From armeria with Apache License 2.0 4 votes vote down vote up
RequestContextCompletableObserver(CompletableObserver actual, RequestContext assemblyContext) {
    this.actual = actual;
    this.assemblyContext = assemblyContext;
}