Package com.tuladb

Class LedgerClientPool

java.lang.Object
com.tuladb.LedgerClientPool
All Implemented Interfaces:
Closeable, AutoCloseable

public final class LedgerClientPool extends Object implements Closeable
A fixed set of connections, so N callers get N requests in flight.

One LedgerClient owns one socket and serialises a complete request/response exchange on it (the wire has no correlation id, so it must). Concurrency therefore comes from connections, not threads: eight threads sharing one client take turns; eight threads over a pool of eight do not.

Members are leader-aware SmartLedgerClient instances and honour the same routing override, so a pool can be pinned to one node exactly like a single client.

Operations this class does not define are reached with withClient(com.tuladb.LedgerClientPool.ClientCall<T>):


 try (LedgerClientPool pool = new LedgerClientPool("ledger://n1:7700,n2:7700", 16, 30_000)) {
     Balance b = pool.withClient(c -> c.getBalance(AccountKey.of(1, 840, accountId)));
     List<TransferResult> r = pool.transferBatch(transfers);   // sharded across members
 }