Search in sources :

Example 1 with Pipes

use of cyclops.futurestream.Pipes in project cyclops by aol.

the class PipesTest method futureStreamCustomTest.

@Test
public void futureStreamCustomTest() {
    Pipes<String, Integer> bus = Pipes.of();
    bus.register("reactor", QueueFactories.<Integer>boundedNonBlockingQueue(1000).build());
    bus.publishTo("reactor", ReactiveSeq.of(10, 20, 30));
    bus.close("reactor");
    System.out.println(Thread.currentThread().getId());
    List<String> res = bus.futureStream("reactor", new LazyReact(10, 10)).toOptional().get().map(i -> "fan-out toNested handle blocking I/O:" + Thread.currentThread().getId() + ":" + i).toList();
    System.out.println(res);
    assertThat(res.size(), equalTo(3));
}
Also used : ListX(cyclops.reactive.collections.mutable.ListX) Arrays(java.util.Arrays) QueueFactories(com.oath.cyclops.async.QueueFactories) LazyReact(cyclops.futurestream.LazyReact) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Assert.assertThat(org.junit.Assert.assertThat) NoSuchElementException(java.util.NoSuchElementException) Pipes(cyclops.futurestream.Pipes) Before(org.junit.Before) cyclops.control(cyclops.control) Executor(java.util.concurrent.Executor) lombok.val(lombok.val) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Executors(java.util.concurrent.Executors) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ReactiveSeq(cyclops.reactive.ReactiveSeq) Flux(reactor.core.publisher.Flux) List(java.util.List) Queue(com.oath.cyclops.async.adapters.Queue) Ignore(org.junit.Ignore) Assert.assertFalse(org.junit.Assert.assertFalse) ForkJoinPool(java.util.concurrent.ForkJoinPool) Matchers.equalTo(org.hamcrest.Matchers.equalTo) QueueBasedSubscriber(com.oath.cyclops.types.reactive.QueueBasedSubscriber) LazyReact(cyclops.futurestream.LazyReact) Test(org.junit.Test)

Example 2 with Pipes

use of cyclops.futurestream.Pipes in project cyclops by aol.

the class PipesTest method publishToTest.

@Test
public void publishToTest() {
    Pipes<String, Integer> bus = Pipes.of();
    bus.register("reactor", QueueFactories.<Integer>boundedNonBlockingQueue(1000).build());
    bus.publishTo("reactor", Flux.just(10, 20, 30));
    bus.close("reactor");
    System.out.println(Thread.currentThread().getId());
    List<String> res = bus.futureStream("reactor", new LazyReact()).toOptional().get().map(i -> "fan-out toNested handle blocking I/O:" + Thread.currentThread().getId() + ":" + i).toList();
    System.out.println(res);
    assertThat(res.size(), equalTo(3));
}
Also used : ListX(cyclops.reactive.collections.mutable.ListX) Arrays(java.util.Arrays) QueueFactories(com.oath.cyclops.async.QueueFactories) LazyReact(cyclops.futurestream.LazyReact) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Assert.assertThat(org.junit.Assert.assertThat) NoSuchElementException(java.util.NoSuchElementException) Pipes(cyclops.futurestream.Pipes) Before(org.junit.Before) cyclops.control(cyclops.control) Executor(java.util.concurrent.Executor) lombok.val(lombok.val) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Executors(java.util.concurrent.Executors) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ReactiveSeq(cyclops.reactive.ReactiveSeq) Flux(reactor.core.publisher.Flux) List(java.util.List) Queue(com.oath.cyclops.async.adapters.Queue) Ignore(org.junit.Ignore) Assert.assertFalse(org.junit.Assert.assertFalse) ForkJoinPool(java.util.concurrent.ForkJoinPool) Matchers.equalTo(org.hamcrest.Matchers.equalTo) QueueBasedSubscriber(com.oath.cyclops.types.reactive.QueueBasedSubscriber) LazyReact(cyclops.futurestream.LazyReact) Test(org.junit.Test)

Example 3 with Pipes

use of cyclops.futurestream.Pipes in project cyclops by aol.

the class PipesTest method futureStreamTest.

@Test
public void futureStreamTest() {
    Pipes<String, Integer> bus = Pipes.of();
    bus.register("reactor", QueueFactories.<Integer>boundedNonBlockingQueue(1000).build());
    bus.publishTo("reactor", ReactiveSeq.of(10, 20, 30));
    bus.close("reactor");
    System.out.println(Thread.currentThread().getId());
    List<String> res = bus.futureStream("reactor", new LazyReact()).toOptional().get().map(i -> "fan-out toNested handle blocking I/O:" + Thread.currentThread().getId() + ":" + i).toList();
    System.out.println(res);
    assertThat(res.size(), equalTo(3));
}
Also used : ListX(cyclops.reactive.collections.mutable.ListX) Arrays(java.util.Arrays) QueueFactories(com.oath.cyclops.async.QueueFactories) LazyReact(cyclops.futurestream.LazyReact) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Assert.assertThat(org.junit.Assert.assertThat) NoSuchElementException(java.util.NoSuchElementException) Pipes(cyclops.futurestream.Pipes) Before(org.junit.Before) cyclops.control(cyclops.control) Executor(java.util.concurrent.Executor) lombok.val(lombok.val) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Executors(java.util.concurrent.Executors) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ReactiveSeq(cyclops.reactive.ReactiveSeq) Flux(reactor.core.publisher.Flux) List(java.util.List) Queue(com.oath.cyclops.async.adapters.Queue) Ignore(org.junit.Ignore) Assert.assertFalse(org.junit.Assert.assertFalse) ForkJoinPool(java.util.concurrent.ForkJoinPool) Matchers.equalTo(org.hamcrest.Matchers.equalTo) QueueBasedSubscriber(com.oath.cyclops.types.reactive.QueueBasedSubscriber) LazyReact(cyclops.futurestream.LazyReact) Test(org.junit.Test)

Aggregations

QueueFactories (com.oath.cyclops.async.QueueFactories)3 Queue (com.oath.cyclops.async.adapters.Queue)3 QueueBasedSubscriber (com.oath.cyclops.types.reactive.QueueBasedSubscriber)3 cyclops.control (cyclops.control)3 LazyReact (cyclops.futurestream.LazyReact)3 Pipes (cyclops.futurestream.Pipes)3 ReactiveSeq (cyclops.reactive.ReactiveSeq)3 ListX (cyclops.reactive.collections.mutable.ListX)3 ArrayList (java.util.ArrayList)3 Arrays (java.util.Arrays)3 HashMap (java.util.HashMap)3 List (java.util.List)3 NoSuchElementException (java.util.NoSuchElementException)3 Executor (java.util.concurrent.Executor)3 Executors (java.util.concurrent.Executors)3 ForkJoinPool (java.util.concurrent.ForkJoinPool)3 lombok.val (lombok.val)3 Matchers.equalTo (org.hamcrest.Matchers.equalTo)3 Matchers.instanceOf (org.hamcrest.Matchers.instanceOf)3 Assert.assertFalse (org.junit.Assert.assertFalse)3