Search in sources :

Example 6 with AssemblySnapshot

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);
}
Also used : AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot) Test(org.junit.jupiter.api.Test)

Example 7 with AssemblySnapshot

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:");
}
Also used : AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot) Test(org.junit.jupiter.api.Test)

Example 8 with AssemblySnapshot

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;
}
Also used : CorePublisher(reactor.core.CorePublisher) Publisher(org.reactivestreams.Publisher) AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot)

Example 9 with AssemblySnapshot

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;
}
Also used : CorePublisher(reactor.core.CorePublisher) Publisher(org.reactivestreams.Publisher) AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot)

Example 10 with AssemblySnapshot

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);
}
Also used : AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot) Test(org.junit.jupiter.api.Test)

Aggregations

AssemblySnapshot (reactor.core.publisher.FluxOnAssembly.AssemblySnapshot)19 Test (org.junit.jupiter.api.Test)15 Publisher (org.reactivestreams.Publisher)4 CorePublisher (reactor.core.CorePublisher)4 Subscription (org.reactivestreams.Subscription)1