rdbc-pool project and this documentation is still a work in progress. It's not ready yet for production use.
The pool configuration is represented by
instance. Instances of this class can be created using its companion object's
apply method. Every parameter of this method has some default value
so you can use named parameters to set only some configuration options and
keep others at defaults.
The list below contains available configuration options.
Name of the pool — appears in logs.
Size of the pool. The pool will maintain at most
sizeconnections at any given time, this includes both idle and in-use connections. If some connection is closed the pool will do its best to replace it as soon as possible so that the pool always contains
Connections are always validated before being returned to clients. If the connection validity can't be determined in this time, the connection is considered invalid and is closed and eventually removed from the pool.
If opening the connection doesn't finish in this time, the attempt is aborted. Note that this property doesn't control the maximum time which clients will wait for connections — it's for pool's internal connection requests.
When clients return connections to the pool, the pool rolls back any transaction that may be in progress so that other clients are unaffected by previous connection usage. This property controls maximum time that the rollback operation can take. If it takes longer the connection is closed and removed from the pool.
A function that creates task scheduler for pool's internal use. The scheduler is used to schedule connection request timeouts.
Default value: A function creating JDK scheduler that uses a single thread and the global execution context for internal asynchronous executions.
() => new JdkScheduler(Executors.newSingleThreadScheduledExecutor()) (ExecutionContext.global)
An execution context that will be used by the pool internally to execute callbacks on
Futures and any asynchronous operations it needs. The operations executed are guaranteed to be non-blocking.
The snippet below creates a pool specifying its name, size and validation timeout.
import scala.concurrent.duration._ import io.rdbc.sapi._ import io.rdbc.pool.sapi._ val cf: ConnectionFactory = ??? val pool = ConnectionPool(cf, ConnectionPoolConfig( name = "mypool", size = 50, validateTimeout = 5.seconds.timeout) )