use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.
the class ConnectableFluxOnAssemblyTest method scanOperator.
@Test
public void scanOperator() {
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.ACTUAL_METADATA)).as("ACTUAL_METADATA").isTrue();
assertThat(test.scan(Scannable.Attr.PREFETCH)).as("PREFETCH").isEqualTo(-1);
assertThat(test.scan(Scannable.Attr.PARENT)).as("PARENT").isSameAs(source);
assertThat(test.scan(Scannable.Attr.RUN_STYLE)).as("RUN_STYLE").isSameAs(Scannable.Attr.RunStyle.SYNC);
}
use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.
the class MonoCallableOnAssemblyTest method stepNameAndToString.
@Test
public void stepNameAndToString() {
AssemblySnapshot stacktrace = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get());
MonoCallableOnAssembly<?> test = new MonoCallableOnAssembly<>(Mono.empty(), stacktrace);
assertThat(test.toString()).isEqualTo(test.stepName()).startsWith("reactor.core.publisher.MonoCallableOnAssemblyTest.stepNameAndToString(MonoCallableOnAssemblyTest.java:");
}
use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.
the class Flux method onAssembly.
/**
* To be used by custom operators: invokes assembly {@link Hooks} pointcut given a
* {@link ConnectableFlux}, potentially returning a new {@link ConnectableFlux}. This
* is for example useful to activate cross-cutting concerns at assembly time, eg. a
* generalized {@link #checkpoint()}.
*
* @param <T> the value type
* @param source the source to apply assembly hooks onto
*
* @return the source, potentially wrapped with assembly time cross-cutting behavior
*/
@SuppressWarnings("unchecked")
protected static <T> ConnectableFlux<T> onAssembly(ConnectableFlux<T> source) {
Function<Publisher, Publisher> hook = Hooks.onEachOperatorHook;
if (hook != null) {
source = (ConnectableFlux<T>) hook.apply(source);
}
if (Hooks.GLOBAL_TRACE) {
AssemblySnapshot stacktrace = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get());
source = (ConnectableFlux<T>) Hooks.addAssemblyInfo(source, stacktrace);
}
return source;
}
use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.
the class Flux method onAssembly.
/**
* To be used by custom operators: invokes assembly {@link Hooks} pointcut given a
* {@link Flux}, potentially returning a new {@link Flux}. This is for example useful
* to activate cross-cutting concerns at assembly time, eg. a generalized
* {@link #checkpoint()}.
*
* @param <T> the value type
* @param source the source to apply assembly hooks onto
*
* @return the source, potentially wrapped with assembly time cross-cutting behavior
*/
@SuppressWarnings("unchecked")
protected static <T> Flux<T> onAssembly(Flux<T> source) {
Function<Publisher, Publisher> hook = Hooks.onEachOperatorHook;
if (hook != null) {
source = (Flux<T>) hook.apply(source);
}
if (Hooks.GLOBAL_TRACE) {
AssemblySnapshot stacktrace = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get());
source = (Flux<T>) Hooks.addAssemblyInfo(source, stacktrace);
}
return source;
}
use of reactor.core.publisher.FluxOnAssembly.AssemblySnapshot in project reactor-core by reactor.
the class FluxCallableOnAssemblyTest method scanOperator.
@Test
public void scanOperator() {
AssemblySnapshot stacktrace = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get());
FluxCallableOnAssembly<?> test = new FluxCallableOnAssembly<>(Flux.empty(), stacktrace);
assertThat(test.scan(Scannable.Attr.ACTUAL_METADATA)).as("ACTUAL_METADATA").isTrue();
assertThat(test.scan(Scannable.Attr.RUN_STYLE)).isSameAs(Scannable.Attr.RunStyle.SYNC);
}
Aggregations