use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.
the class ParallelFlux method onAssembly.
/**
* Invoke {@link Hooks} pointcut given a {@link ParallelFlux} and returning an
* eventually new {@link ParallelFlux}
*
* @param <T> the value type
* @param source the source to wrap
*
* @return the potentially wrapped source
*/
@SuppressWarnings("unchecked")
protected static <T> ParallelFlux<T> onAssembly(ParallelFlux<T> source) {
Function<Publisher, Publisher> hook = Hooks.onEachOperatorHook;
if (hook != null) {
source = (ParallelFlux<T>) hook.apply(source);
}
if (Hooks.GLOBAL_TRACE) {
AssemblySnapshot stacktrace = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get());
source = (ParallelFlux<T>) Hooks.addAssemblyInfo(source, stacktrace);
}
return source;
}
use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.
the class FluxOnAssemblyTest method scanSubscriber.
@Test
void scanSubscriber() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
AssemblySnapshot snapshot = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get());
FluxOnAssembly.OnAssemblySubscriber<Integer> test = new FluxOnAssembly.OnAssemblySubscriber<>(actual, snapshot, Flux.just(1), Flux.empty());
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.RUN_STYLE)).isSameAs(Scannable.Attr.RunStyle.SYNC);
}
use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.
the class ParallelFluxOnAssemblyTest method stepNameAndToString.
@Test
public void stepNameAndToString() {
ParallelFlux<Integer> source = Flux.range(1, 4).parallel(3);
AssemblySnapshot stacktrace = new AssemblySnapshot("foo", Traces.callSiteSupplierFactory.get());
ParallelFluxOnAssembly<Integer> test = new ParallelFluxOnAssembly<>(source, stacktrace);
assertThat(test.toString()).isEqualTo(test.stepName()).startsWith("reactor.core.publisher.ParallelFluxOnAssemblyTest.stepNameAndToString(ParallelFluxOnAssemblyTest.java:");
}
use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.
the class ParallelFluxOnAssemblyTest method scanOperator.
@Test
public void scanOperator() {
ParallelFlux<Integer> source = Flux.range(1, 4).parallel(3);
AssemblySnapshot stacktrace = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get());
ParallelFluxOnAssembly<Integer> test = new ParallelFluxOnAssembly<>(source, stacktrace);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(256).isEqualTo(source.getPrefetch());
assertThat(test.scan(Scannable.Attr.ACTUAL_METADATA)).as("ACTUAL_METADATA").isTrue();
assertThat(test.scan(RUN_STYLE)).isSameAs(SYNC);
}
use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.
the class ConnectableFluxOnAssemblyTest method scanMain.
@Test
public void scanMain() {
ConnectableFlux<String> source = Flux.just("foo").publish();
AssemblySnapshot stacktrace = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get());
ConnectableFluxOnAssembly<String> test = new ConnectableFluxOnAssembly<>(source, stacktrace);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(-1);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source);
assertThat(test.scan(Scannable.Attr.RUN_STYLE)).isSameAs(Scannable.Attr.RunStyle.SYNC);
}
Aggregations