com.github.mauricio.async.db.pool

Type members

Classlikes

Defines the common interface for async object pools. These are pools that do not block clients trying to acquire a resource from it. Different than the usual synchronous pool, you must return objects back to it manually since it's impossible for the pool to know when the object is ready to be given back.

Defines the common interface for async object pools. These are pools that do not block clients trying to acquire a resource from it. Different than the usual synchronous pool, you must return objects back to it manually since it's impossible for the pool to know when the object is ready to be given back.

class ConnectionPool[T <: Connection](factory: ObjectFactory[T], configuration: PoolConfiguration, executionContext: ExecutionContext) extends SingleThreadedAsyncObjectPool[T] with Connection

Pool specialized in database connections that also simplifies connection handling by implementing the com.github.mauricio.async.db.Connection trait and saving clients from having to implement the "give back" part of pool management. This lets you do your job without having to worry about managing and giving back connection objects to the pool.

Pool specialized in database connections that also simplifies connection handling by implementing the com.github.mauricio.async.db.Connection trait and saving clients from having to implement the "give back" part of pool management. This lets you do your job without having to worry about managing and giving back connection objects to the pool.

The downside of this is that you should not start transactions or any kind of long running process in this object as the object will be sent back to the pool right after executing a query. If you need to start transactions you will have to take an object from the pool, do it and then give it back manually.

trait ObjectFactory[T]

Definition for objects that can be used as a factory for com.github.mauricio.async.db.pool.AsyncObjectPool objects.

Definition for objects that can be used as a factory for com.github.mauricio.async.db.pool.AsyncObjectPool objects.

Type Params
T

the kind of object this factory produces.

class PartitionedAsyncObjectPool[T](factory: ObjectFactory[T], configuration: PoolConfiguration, numberOfPartitions: Int) extends AsyncObjectPool[T]
class PartitionedConnectionPool[T <: Connection](factory: ObjectFactory[T], configuration: PoolConfiguration, numberOfPartitions: Int, executionContext: ExecutionContext) extends PartitionedAsyncObjectPool[T] with Connection
class PoolAlreadyTerminatedException extends IllegalStateException

Thrown when the pool has already been closed.

Thrown when the pool has already been closed.

Companion
class
case
class PoolConfiguration(maxObjects: Int, maxIdle: Long, maxQueueSize: Int, validationInterval: Long)

Defines specific pieces of a pool's behavior.

Defines specific pieces of a pool's behavior.

Value Params
maxIdle

number of milliseconds for which the objects are going to be kept as idle (not in use by clients of the pool)

maxObjects

how many objects this pool will hold

maxQueueSize

when there are no more objects, the pool can queue up requests to serve later then there are objects available, this is the maximum number of enqueued requests

validationInterval

pools will use this value as the timer period to validate idle objects.

Companion
object
class PoolExhaustedException(message: String) extends IllegalStateException

Raised when a pool has reached it's limit of available objects.

Raised when a pool has reached it's limit of available objects.

class SingleThreadedAsyncObjectPool[T](factory: ObjectFactory[T], configuration: PoolConfiguration) extends AsyncObjectPool[T]

Implements an com.github.mauricio.async.db.pool.AsyncObjectPool using a single thread from a fixed executor service as an event loop to cause all calls to be sequential.

Implements an com.github.mauricio.async.db.pool.AsyncObjectPool using a single thread from a fixed executor service as an event loop to cause all calls to be sequential.

Once you are done with this object remember to call it's close method to clean up the thread pool and it's objects as this might prevent your application from ending.

Type Params
T

type of the object this pool holds

Companion
object