Search in sources :

Example 1 with NonBlockingMember

use of org.davidmoten.rx.pool.NonBlockingMember in project rxjava2-jdbc by davidmoten.

the class PoolTest method testSimplePool.

@Test
public void testSimplePool() throws InterruptedException {
    AtomicInteger count = new AtomicInteger();
    MemberFactory<Integer, NonBlockingPool<Integer>> memberFactory = pool -> new NonBlockingMember<Integer>(pool, null);
    Pool<Integer> pool = //
    NonBlockingPool.factory(() -> count.incrementAndGet()).healthy(//
    n -> true).disposer(n -> {
    }).maxSize(//
    3).returnToPoolDelayAfterHealthCheckFailureMs(//
    1000).memberFactory(//
    memberFactory).scheduler(//
    Schedulers.computation()).build();
    //
    pool.members().doOnNext(//
    m -> m.checkin()).doOnNext(//
    System.out::println).test(4).assertValueCount(4);
}
Also used : NonBlockingPool(org.davidmoten.rx.pool.NonBlockingPool) Arrays(java.util.Arrays) Connection(java.sql.Connection) Database(org.davidmoten.rx.jdbc.Database) Pool(org.davidmoten.rx.pool.Pool) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) MemberFactory(org.davidmoten.rx.pool.MemberFactory) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) List(java.util.List) NonBlockingMember(org.davidmoten.rx.pool.NonBlockingMember) Flowable(io.reactivex.Flowable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Schedulers(io.reactivex.schedulers.Schedulers) TestSubscriber(io.reactivex.subscribers.TestSubscriber) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NonBlockingPool(org.davidmoten.rx.pool.NonBlockingPool) NonBlockingMember(org.davidmoten.rx.pool.NonBlockingMember) Test(org.junit.Test)

Aggregations

Flowable (io.reactivex.Flowable)1 Schedulers (io.reactivex.schedulers.Schedulers)1 TestSubscriber (io.reactivex.subscribers.TestSubscriber)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Database (org.davidmoten.rx.jdbc.Database)1 MemberFactory (org.davidmoten.rx.pool.MemberFactory)1 NonBlockingMember (org.davidmoten.rx.pool.NonBlockingMember)1 NonBlockingPool (org.davidmoten.rx.pool.NonBlockingPool)1 Pool (org.davidmoten.rx.pool.Pool)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Test (org.junit.Test)1