Java Code Examples for io.reactivex.CompletableObserver#onSubscribe()
The following examples show how to use
io.reactivex.CompletableObserver#onSubscribe() .
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 |
@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 |
@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 |
@Override protected void subscribeActual(CompletableObserver downstream) { if (bulkhead.tryAcquirePermission()) { upstream.subscribe(new BulkheadCompletableObserver(downstream)); } else { downstream.onSubscribe(EmptyDisposable.INSTANCE); downstream.onError(BulkheadFullException.createBulkheadFullException(bulkhead)); } }