Search in sources :

Example 1 with AssemblySnapshot

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

Example 2 with AssemblySnapshot

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

Example 3 with AssemblySnapshot

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

Example 4 with AssemblySnapshot

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

Example 5 with AssemblySnapshot

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);
}
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