Java Code Examples for reactor.core.publisher.Operators#error()
The following examples show how to use
reactor.core.publisher.Operators#error() .
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: FutureMono.java From reactor-netty with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("FutureReturnValueIgnored") public final void subscribe(final CoreSubscriber<? super Void> s) { if(future.isDone()){ if(future.isSuccess()){ Operators.complete(s); } else{ Operators.error(s, FutureSubscription.wrapError(future.cause())); } return; } FutureSubscription<F> fs = new FutureSubscription<>(future, s); // Returned value is deliberately ignored future.addListener(fs); s.onSubscribe(fs); }
Example 2
Source File: HttpClientOperations.java From reactor-netty with Apache License 2.0 | 6 votes |
@Override public void subscribe(CoreSubscriber<? super Void> s) { if (!parent.markSentHeaders()) { Operators.error(s, new IllegalStateException("headers have already been sent")); return; } Subscription subscription = Operators.emptySubscription(); s.onSubscribe(subscription); if (parent.channel() .eventLoop() .inEventLoop()) { _subscribe(s); } else { parent.channel() .eventLoop() .execute(() -> _subscribe(s)); } }
Example 3
Source File: UnboundedProcessor.java From rsocket-java with Apache License 2.0 | 6 votes |
@Override public void subscribe(CoreSubscriber<? super T> actual) { Objects.requireNonNull(actual, "subscribe"); if (once == 0 && ONCE.compareAndSet(this, 0, 1)) { actual.onSubscribe(this); this.actual = actual; if (cancelled) { this.hasDownstream = false; } else { drain(); } } else { Operators.error( actual, new IllegalStateException("UnboundedProcessor " + "allows only a single Subscriber")); } }
Example 4
Source File: FutureMono.java From reactor-netty with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("FutureReturnValueIgnored") public void subscribe(CoreSubscriber<? super Void> s) { F f; try { f = deferredFuture.get(); } catch(Throwable t) { Operators.error(s, t); return; } if (f == null) { Operators.error(s, Operators.onOperatorError(new NullPointerException( "Deferred supplied null"), s.currentContext())); return; } if (f.isDone()) { if (f.isSuccess()) { Operators.complete(s); } else { Operators.error(s, FutureSubscription.wrapError(f.cause())); } return; } FutureSubscription<F> fs = new FutureSubscription<>(f, s); s.onSubscribe(fs); // Returned value is deliberately ignored f.addListener(fs); }
Example 5
Source File: FluxReceive.java From reactor-netty with Apache License 2.0 | 5 votes |
@Override public void subscribe(CoreSubscriber<? super Object> s) { if (once == 0 && ONCE.compareAndSet(this, 0, 1)) { if (log.isDebugEnabled()) { log.debug(format(channel, "Subscribing inbound receiver [pending: {}, cancelled:{}, " + "inboundDone: {}]"), getPending(), isCancelled(), inboundDone); } if (inboundDone && getPending() == 0) { if (inboundError != null) { Operators.error(s, inboundError); return; } Operators.complete(s); return; } receiver = s; s.onSubscribe(this); } else { if (inboundDone && getPending() == 0) { if (inboundError != null) { Operators.error(s, inboundError); return; } Operators.complete(s); } else { Operators.error(s, new IllegalStateException( "Only one connection receive subscriber allowed.")); } } }
Example 6
Source File: MonoCircuitBreaker.java From resilience4j with Apache License 2.0 | 5 votes |
@Override public void subscribe(CoreSubscriber<? super T> actual) { if (circuitBreaker.tryAcquirePermission()) { source.subscribe(new CircuitBreakerSubscriber<>(circuitBreaker, actual, true)); } else { Operators.error(actual, createCallNotPermittedException(circuitBreaker)); } }
Example 7
Source File: FluxCircuitBreaker.java From resilience4j with Apache License 2.0 | 5 votes |
@Override public void subscribe(CoreSubscriber<? super T> actual) { if (circuitBreaker.tryAcquirePermission()) { source.subscribe(new CircuitBreakerSubscriber<>(circuitBreaker, actual, false)); } else { Operators.error(actual, createCallNotPermittedException(circuitBreaker)); } }
Example 8
Source File: FluxBulkhead.java From resilience4j with Apache License 2.0 | 5 votes |
@Override public void subscribe(CoreSubscriber<? super T> actual) { if (bulkhead.tryAcquirePermission()) { source.subscribe(new BulkheadSubscriber<>(bulkhead, actual, false)); } else { Operators.error(actual, BulkheadFullException.createBulkheadFullException(bulkhead)); } }
Example 9
Source File: MonoBulkhead.java From resilience4j with Apache License 2.0 | 5 votes |
@Override public void subscribe(CoreSubscriber<? super T> actual) { if (bulkhead.tryAcquirePermission()) { source.subscribe(new BulkheadSubscriber<>(bulkhead, actual, true)); } else { Operators.error(actual, BulkheadFullException.createBulkheadFullException(bulkhead)); } }
Example 10
Source File: FluxRateLimiter.java From resilience4j with Apache License 2.0 | 5 votes |
@Override public void subscribe(CoreSubscriber<? super T> actual) { long waitDuration = rateLimiter.reservePermission(); if (waitDuration >= 0) { if (waitDuration > 0) { Mono.delay(Duration.ofNanos(waitDuration)) .subscribe(delay -> source.subscribe(new RateLimiterSubscriber<>(actual))); } else { source.subscribe(new RateLimiterSubscriber<>(actual)); } } else { Operators.error(actual, createRequestNotPermitted(rateLimiter)); } }
Example 11
Source File: MonoRateLimiter.java From resilience4j with Apache License 2.0 | 5 votes |
@Override public void subscribe(CoreSubscriber<? super T> actual) { long waitDuration = rateLimiter.reservePermission(); if (waitDuration >= 0) { if (waitDuration > 0) { Mono.delay(Duration.ofNanos(waitDuration)) .subscribe(delay -> source.subscribe(new RateLimiterSubscriber<>(actual))); } else { source.subscribe(new RateLimiterSubscriber<>(actual)); } } else { Operators.error(actual, createRequestNotPermitted(rateLimiter)); } }