Java Code Examples for reactor.util.context.Context#empty()
The following examples show how to use
reactor.util.context.Context#empty() .
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: MonoPublishMulticastTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanMulticastInner() { CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null); MonoPublishMulticast.MonoPublishMulticaster<Integer> parent = new MonoPublishMulticast.MonoPublishMulticaster<>(Context.empty()); MonoPublishMulticast.PublishMulticastInner<Integer> test = new MonoPublishMulticast.PublishMulticastInner<>(parent, actual); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual); test.request(789); //does not track request in the Mono version assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(0); assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse(); test.cancel(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); }
Example 2
Source File: FluxPublishMulticastTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanMulticaster() { FluxPublishMulticast.FluxPublishMulticaster<Integer> test = new FluxPublishMulticast.FluxPublishMulticaster<>(123, Queues.<Integer>unbounded(), Context.empty()); Subscription parent = Operators.emptySubscription(); test.onSubscribe(parent); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent); assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123); assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(0); test.queue.add(1); assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1); assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); assertThat(test.scan(Scannable.Attr.ERROR)).isNull(); test.error = new IllegalArgumentException("boom"); assertThat(test.scan(Scannable.Attr.ERROR)).isSameAs(test.error); test.onComplete(); assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse(); test.terminate(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); }
Example 3
Source File: MonoPublishMulticastTest.java From reactor-core with Apache License 2.0 | 6 votes |
@Test public void scanMulticaster() { MonoPublishMulticast.MonoPublishMulticaster<Integer> test = new MonoPublishMulticast.MonoPublishMulticaster<>(Context.empty()); Subscription parent = Operators.emptySubscription(); test.onSubscribe(parent); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent); assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(1); assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(0); test.value = 1; assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1); assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse(); assertThat(test.scan(Scannable.Attr.ERROR)).isNull(); test.error = new IllegalArgumentException("boom"); assertThat(test.scan(Scannable.Attr.ERROR)).isSameAs(test.error); test.onComplete(); assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse(); test.terminate(); assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue(); }
Example 4
Source File: DefaultGatewayClient.java From Discord4J with GNU Lesser General Public License v3.0 | 5 votes |
private Context getContextFromException(Throwable t) { if (t instanceof CloseException) { return ((CloseException) t).getContext(); } if (t instanceof GatewayException) { return ((GatewayException) t).getContext(); } return Context.empty(); }
Example 5
Source File: DelegateProcessor.java From reactor-core with Apache License 2.0 | 5 votes |
@Override public Context currentContext() { if(upstream instanceof CoreSubscriber){ return ((CoreSubscriber)upstream).currentContext(); } return Context.empty(); }
Example 6
Source File: ScopePassingSpanSubscriberTests.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_put_current_span_to_context() { try (Scope ws = this.currentTraceContext.newScope(context2)) { CoreSubscriber<?> subscriber = new ScopePassingSpanSubscriber<>( new BaseSubscriber<Object>() { }, Context.empty(), currentTraceContext, context); then(subscriber.currentContext().get(TraceContext.class)).isEqualTo(context); } }
Example 7
Source File: FluxWindowPredicate.java From reactor-core with Apache License 2.0 | 5 votes |
void drainFused(Subscriber<? super T> a) { int missed = 1; final Queue<T> q = queue; for (; ; ) { if (cancelled) { Operators.onDiscardQueueWithClear(q, ctx, null); ctx = Context.empty(); actual = null; return; } boolean d = done; a.onNext(null); if (d) { ctx = Context.empty(); actual = null; Throwable ex = error; if (ex != null) { a.onError(ex); } else { a.onComplete(); } return; } missed = WIP.addAndGet(this, -missed); if (missed == 0) { break; } } }
Example 8
Source File: FluxPublishMulticastTest.java From reactor-core with Apache License 2.0 | 5 votes |
@Test public void scanCancelMulticaster() { CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null); FluxPublishMulticast.FluxPublishMulticaster<Integer> parent = new FluxPublishMulticast.FluxPublishMulticaster<>(123, Queues.<Integer>unbounded(), Context.empty()); FluxPublishMulticast.CancelMulticaster<Integer> test = new FluxPublishMulticast.CancelMulticaster<>(actual, parent); Subscription sub = Operators.emptySubscription(); test.onSubscribe(sub); assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(sub); assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual); }
Example 9
Source File: TestHttpCallbackSubscriber.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
@Override public Context currentContext() { return Context.empty(); }
Example 10
Source File: StatsdMeterRegistry.java From micrometer with Apache License 2.0 | 4 votes |
@Override public Context currentContext() { return Context.empty(); }
Example 11
Source File: AssertSubscriber.java From rsocket-java with Apache License 2.0 | 4 votes |
public AssertSubscriber() { this(Context.empty(), Long.MAX_VALUE); }
Example 12
Source File: BlockingSingleSubscriber.java From reactor-core with Apache License 2.0 | 4 votes |
@Override public Context currentContext() { return Context.empty(); }
Example 13
Source File: BlockingOptionalMonoSubscriber.java From reactor-core with Apache License 2.0 | 4 votes |
@Override public Context currentContext() { return Context.empty(); }
Example 14
Source File: StrictSubscriber.java From reactor-core with Apache License 2.0 | 4 votes |
@Override public Context currentContext() { return Context.empty(); }
Example 15
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 16
Source File: FluxPeekFuseableTest.java From reactor-core with Apache License 2.0 | 4 votes |
ConditionalAssertSubscriber() { this(Context.empty()); }
Example 17
Source File: Operators.java From reactor-core with Apache License 2.0 | 4 votes |
@Override public Context currentContext() { return Context.empty(); }
Example 18
Source File: Operators.java From reactor-core with Apache License 2.0 | 4 votes |
@Override public Context currentContext() { return Context.empty(); }
Example 19
Source File: LambdaSubscriber.java From reactor-core with Apache License 2.0 | 3 votes |
/** * Create a {@link Subscriber} reacting onNext, onError and onComplete. If no * {@code subscriptionConsumer} is provided, the subscriber will automatically request * Long.MAX_VALUE in onSubscribe, as well as an initial {@link Context} that will be * visible by operators upstream in the chain. * * @param consumer A {@link Consumer} with argument onNext data * @param errorConsumer A {@link Consumer} called onError * @param completeConsumer A {@link Runnable} called onComplete with the actual * context if any * @param subscriptionConsumer A {@link Consumer} called with the {@link Subscription} * to perform initial request, or null to request max * @param initialContext A {@link Context} for this subscriber, or null to use the default * of an {@link Context#empty() empty Context}. */ LambdaSubscriber( @Nullable Consumer<? super T> consumer, @Nullable Consumer<? super Throwable> errorConsumer, @Nullable Runnable completeConsumer, @Nullable Consumer<? super Subscription> subscriptionConsumer, @Nullable Context initialContext) { this.consumer = consumer; this.errorConsumer = errorConsumer; this.completeConsumer = completeConsumer; this.subscriptionConsumer = subscriptionConsumer; this.initialContext = initialContext == null ? Context.empty() : initialContext; }
Example 20
Source File: CoreSubscriber.java From reactor-core with Apache License 2.0 | 2 votes |
/** * Request a {@link Context} from dependent components which can include downstream * operators during subscribing or a terminal {@link org.reactivestreams.Subscriber}. * * @return a resolved context or {@link Context#empty()} */ default Context currentContext(){ return Context.empty(); }