Java Code Examples for reactor.core.CoreSubscriber#currentContext()
The following examples show how to use
reactor.core.CoreSubscriber#currentContext() .
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: FluxDeferWithContext.java From reactor-core with Apache License 2.0 | 6 votes |
@Override public void subscribe(CoreSubscriber<? super T> actual) { Publisher<? extends T> p; Context ctx = actual.currentContext(); try { p = Objects.requireNonNull(supplier.apply(ctx), "The Publisher returned by the supplier is null"); } catch (Throwable e) { Operators.error(actual, Operators.onOperatorError(e, ctx)); return; } from(p).subscribe(actual); }
Example 2
Source File: TraceWebClientBeanPostProcessor.java From spring-cloud-sleuth with Apache License 2.0 | 6 votes |
@Override public void subscribe(CoreSubscriber<? super ClientResponse> subscriber) { Context context = subscriber.currentContext(); ClientRequestWrapper wrapper = new ClientRequestWrapper(request); Span span = handler.handleSendWithParent(wrapper, parent); if (log.isDebugEnabled()) { log.debug("HttpClientHandler::handleSend: " + span); } // NOTE: We are starting the client span for the request here, but it could be // canceled prior to actually being invoked. TraceWebClientSubscription will // abandon this span, if cancel() happens before request(). this.next.exchange(wrapper.buildRequest()).subscribe( new TraceWebClientSubscriber(subscriber, context, span, this)); }
Example 3
Source File: MonoDeferWithContext.java From reactor-core with Apache License 2.0 | 6 votes |
@Override public void subscribe(CoreSubscriber<? super T> actual) { Mono<? extends T> p; Context ctx = actual.currentContext(); try { p = Objects.requireNonNull(supplier.apply(ctx), "The Mono returned by the supplier is null"); } catch (Throwable e) { Operators.error(actual, Operators.onOperatorError(e, ctx)); return; } p.subscribe(actual); }
Example 4
Source File: FluxPublishMulticast.java From reactor-core with Apache License 2.0 | 6 votes |
@Override public CoreSubscriber<? super T> subscribeOrReturn(CoreSubscriber<? super R> actual) { FluxPublishMulticaster<T> multicast = new FluxPublishMulticaster<>(prefetch, queueSupplier, actual.currentContext()); Publisher<? extends R> out = Objects.requireNonNull(transform.apply(multicast), "The transform returned a null Publisher"); if (out instanceof Fuseable) { out.subscribe(new CancelFuseableMulticaster<>(actual, multicast)); } else { out.subscribe(new CancelMulticaster<>(actual, multicast)); } return multicast; }
Example 5
Source File: ParallelDoOnEach.java From reactor-core with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void subscribe(CoreSubscriber<? super T>[] subscribers) { if (!validate(subscribers)) { return; } int n = subscribers.length; CoreSubscriber<? super T>[] parents = new CoreSubscriber[n]; boolean conditional = subscribers[0] instanceof Fuseable.ConditionalSubscriber; for (int i = 0; i < n; i++) { CoreSubscriber<? super T> subscriber = subscribers[i]; SignalPeek<T> signalPeek = new DoOnEachSignalPeek(subscriber.currentContext()); if (conditional) { parents[i] = new FluxPeekFuseable.PeekConditionalSubscriber<>( (Fuseable.ConditionalSubscriber<T>) subscriber, signalPeek); } else { parents[i] = new FluxPeek.PeekSubscriber<>(subscriber, signalPeek); } } source.subscribe(parents); }
Example 6
Source File: FluxDistinctUntilChanged.java From reactor-core with Apache License 2.0 | 5 votes |
DistinctUntilChangedSubscriber(CoreSubscriber<? super T> actual, Function<? super T, K> keyExtractor, BiPredicate<? super K, ? super K> keyComparator) { this.actual = actual; this.ctx = actual.currentContext(); this.keyExtractor = keyExtractor; this.keyComparator = keyComparator; }
Example 7
Source File: FluxRepeatWhen.java From reactor-core with Apache License 2.0 | 5 votes |
RepeatWhenMainSubscriber(CoreSubscriber<? super T> actual, Subscriber<Long> signaller, CorePublisher<? extends T> source) { super(actual); this.signaller = signaller; this.source = source; this.otherArbiter = new Operators.DeferredSubscription(); this.context = actual.currentContext(); }
Example 8
Source File: FluxDistinct.java From reactor-core with Apache License 2.0 | 5 votes |
DistinctSubscriber(CoreSubscriber<? super T> actual, C collection, Function<? super T, ? extends K> keyExtractor, BiPredicate<C, K> distinctPredicate, Consumer<C> cleanupCallback) { this.actual = actual; this.ctx = actual.currentContext(); this.collection = collection; this.keyExtractor = keyExtractor; this.distinctPredicate = distinctPredicate; this.cleanupCallback = cleanupCallback; }
Example 9
Source File: FluxRetryWhen.java From reactor-core with Apache License 2.0 | 5 votes |
RetryWhenMainSubscriber(CoreSubscriber<? super T> actual, Subscriber<Retry.RetrySignal> signaller, CorePublisher<? extends T> source) { super(actual); this.signaller = signaller; this.source = source; this.otherArbiter = new Operators.DeferredSubscription(); this.context = actual.currentContext(); }
Example 10
Source File: FluxBufferWhen.java From reactor-core with Apache License 2.0 | 5 votes |
BufferWhenMainSubscriber(CoreSubscriber<? super BUFFER> actual, Supplier<BUFFER> bufferSupplier, Supplier<? extends Queue<BUFFER>> queueSupplier, Publisher<? extends OPEN> bufferOpen, Function<? super OPEN, ? extends Publisher<? extends CLOSE>> bufferClose) { this.actual = actual; this.ctx = actual.currentContext(); this.bufferOpen = bufferOpen; this.bufferClose = bufferClose; this.bufferSupplier = bufferSupplier; this.queue = queueSupplier.get(); this.buffers = new LinkedHashMap<>(); this.subscribers = Disposables.composite(); }
Example 11
Source File: FluxWindow.java From reactor-core with Apache License 2.0 | 5 votes |
WindowSkipSubscriber(CoreSubscriber<? super Flux<T>> actual, int size, int skip, Supplier<? extends Queue<T>> processorQueueSupplier) { this.actual = actual; this.ctx = actual.currentContext(); this.size = size; this.skip = skip; this.processorQueueSupplier = processorQueueSupplier; WINDOW_COUNT.lazySet(this, 1); }
Example 12
Source File: FluxDoOnEach.java From reactor-core with Apache License 2.0 | 5 votes |
DoOnEachSubscriber(CoreSubscriber<? super T> actual, Consumer<? super Signal<T>> onSignal, boolean monoFlavor) { this.actual = actual; this.cachedContext = actual.currentContext(); this.onSignal = onSignal; this.state = monoFlavor ? STATE_MONO_START : STATE_FLUX_START; }
Example 13
Source File: FluxOnBackpressureBuffer.java From reactor-core with Apache License 2.0 | 5 votes |
BackpressureBufferSubscriber(CoreSubscriber<? super T> actual, int bufferSize, boolean unbounded, @Nullable Consumer<? super T> onOverflow) { this.actual = actual; this.ctx = actual.currentContext(); this.onOverflow = onOverflow; Queue<T> q; if (unbounded) { q = Queues.<T>unbounded(bufferSize).get(); } else { q = Queues.<T>get(bufferSize).get(); } if (!unbounded && Queues.capacity(q) > bufferSize) { this.capacityOrSkip = bufferSize; } else { //for unbounded, the bufferSize is not terribly relevant //for bounded, if the queue has exact capacity then when checking q.size() == capacityOrSkip, this will skip the check this.capacityOrSkip = Integer.MAX_VALUE; } this.queue = q; }
Example 14
Source File: FluxBuffer.java From reactor-core with Apache License 2.0 | 5 votes |
BufferSkipSubscriber(CoreSubscriber<? super C> actual, int size, int skip, Supplier<C> bufferSupplier) { this.actual = actual; this.ctx = actual.currentContext(); this.size = size; this.skip = skip; this.bufferSupplier = bufferSupplier; }
Example 15
Source File: FluxFilterWhen.java From reactor-core with Apache License 2.0 | 5 votes |
FluxFilterWhenSubscriber(CoreSubscriber<? super T> actual, Function<? super T, ? extends Publisher<Boolean>> asyncPredicate, int bufferSize) { this.actual = actual; this.ctx = actual.currentContext(); this.toFilter = new AtomicReferenceArray<>(Queues.ceilingNextPowerOfTwo(bufferSize)); this.asyncPredicate = asyncPredicate; this.bufferSize = bufferSize; }
Example 16
Source File: FluxSample.java From reactor-core with Apache License 2.0 | 4 votes |
SampleMainSubscriber(CoreSubscriber<? super T> actual) { this.actual = actual; this.ctx = actual.currentContext(); }
Example 17
Source File: UnicastProcessor.java From reactor-core with Apache License 2.0 | 4 votes |
@Override public Context currentContext() { CoreSubscriber<? super T> actual = this.actual; return actual != null ? actual.currentContext() : Context.empty(); }
Example 18
Source File: FluxSkipUntil.java From reactor-core with Apache License 2.0 | 4 votes |
SkipUntilSubscriber(CoreSubscriber<? super T> actual, Predicate<? super T> predicate) { this.actual = actual; this.ctx = actual.currentContext(); this.predicate = predicate; }
Example 19
Source File: FluxFilterFuseable.java From reactor-core with Apache License 2.0 | 4 votes |
FilterFuseableSubscriber(CoreSubscriber<? super T> actual, Predicate<? super T> predicate) { this.actual = actual; this.ctx = actual.currentContext(); this.predicate = predicate; }
Example 20
Source File: FluxFilter.java From reactor-core with Apache License 2.0 | 4 votes |
FilterSubscriber(CoreSubscriber<? super T> actual, Predicate<? super T> predicate) { this.actual = actual; this.ctx = actual.currentContext(); this.predicate = predicate; }