Java源码示例:io.reactivex.rxjava3.core.SingleObserver
示例1
@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));
}
}
示例2
@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));
}
}
示例3
@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));
}
}
示例4
CircuitBreakerSingleObserver(SingleObserver<? super T> downstreamObserver) {
super(downstreamObserver);
this.start = System.nanoTime();
}
示例5
BulkheadSingleObserver(SingleObserver<? super T> downstreamObserver) {
super(downstreamObserver);
}
示例6
public AbstractSingleObserver(SingleObserver<? super T> downstreamObserver) {
this.downstreamObserver = requireNonNull(downstreamObserver);
}
示例7
RateLimiterSingleObserver(SingleObserver<? super T> downstreamObserver) {
super(downstreamObserver);
}
示例8
RequestContextSingleObserver(SingleObserver<T> actual, RequestContext assemblyContext) {
this.actual = actual;
this.assemblyContext = assemblyContext;
}
示例9
@Override
protected void subscribeActual(SingleObserver<? super T> s) {
try (SafeCloseable ignored = assemblyContext.push()) {
source.subscribe(new RequestContextSingleObserver<>(s, assemblyContext));
}
}
示例10
@Override
protected void subscribeActual(SingleObserver<? super T> s) {
try (SafeCloseable ignored = assemblyContext.push()) {
source.subscribe(new RequestContextSingleObserver<>(s, assemblyContext));
}
}
示例11
@Override
protected void subscribeActual(SingleObserver<? super T> s) {
try (SafeCloseable ignored = assemblyContext.push()) {
source.subscribe(new RequestContextSingleObserver<>(s, assemblyContext));
}
}