com.github.mauricio.async.db.pool

ConnectionPool

class ConnectionPool[T <: Connection] 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.

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.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ConnectionPool
  2. Connection
  3. SingleThreadedAsyncObjectPool
  4. AsyncObjectPool
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ConnectionPool(factory: ObjectFactory[T], configuration: PoolConfiguration, executionContext: ExecutionContext = ...)

    factory
    configuration

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def availables: Traversable[T]

  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def close: Future[AsyncObjectPool[T]]

    Closes this pool and future calls to **take** will cause the scala.concurrent.Future to raise an com.github.mauricio.async.db.pool.PoolAlreadyTerminatedException.

    Closes this pool and future calls to **take** will cause the scala.concurrent.Future to raise an com.github.mauricio.async.db.pool.PoolAlreadyTerminatedException.

    returns

    Definition Classes
    SingleThreadedAsyncObjectPoolAsyncObjectPool
  10. def connect: Future[Connection]

    Always returns an empty map.

    Always returns an empty map.

    returns

    Definition Classes
    ConnectionPoolConnection
  11. def disconnect: Future[Connection]

    Closes the pool, you should discard the object.

    Closes the pool, you should discard the object.

    returns

    Definition Classes
    ConnectionPoolConnection
  12. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  14. def finalize(): Unit

    Definition Classes
    SingleThreadedAsyncObjectPool → AnyRef
  15. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  16. def giveBack(item: T): Future[AsyncObjectPool[T]]

    Returns an object to the pool.

    Returns an object to the pool. The object is validated before being added to the collection of available objects to make sure we have a usable object. If the object isn't valid it's discarded.

    item
    returns

    Definition Classes
    SingleThreadedAsyncObjectPoolAsyncObjectPool
  17. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  18. def inTransaction[A](f: (Connection) ⇒ Future[A])(implicit context: ExecutionContext = executionContext): Future[A]

    Picks one connection and executes an (asynchronous) function on it within a transaction block.

    Picks one connection and executes an (asynchronous) function on it within a transaction block. If the function completes successfully, the transaction is committed, otherwise it is aborted. Either way, the connection is returned to the pool on completion.

    f

    operation to execute on a connection

    returns

    result of f, conditional on transaction operations succeeding

    Definition Classes
    ConnectionPoolConnection
  19. def inUse: Traversable[T]

  20. def isClosed: Boolean

  21. def isConnected: Boolean

    Checks whether we are still connected to the database.

    Checks whether we are still connected to the database.

    returns

    Definition Classes
    ConnectionPoolConnection
  22. def isFull: Boolean

  23. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  24. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  25. final def notify(): Unit

    Definition Classes
    AnyRef
  26. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  27. def queued: Traversable[Promise[T]]

  28. def sendPreparedStatement(query: String, values: Seq[Any] = List()): Future[QueryResult]

    Picks one connection and runs this query against it.

    Picks one connection and runs this query against it. The query should be stateless, it should not start transactions and should not leave anything to be cleaned up in the future. The behavior of this object is undefined if you start a transaction from this method.

    query
    values
    returns

    Definition Classes
    ConnectionPoolConnection
  29. def sendQuery(query: String): Future[QueryResult]

    Picks one connection and runs this query against it.

    Picks one connection and runs this query against it. The query should be stateless, it should not start transactions and should not leave anything to be cleaned up in the future. The behavior of this object is undefined if you start a transaction from this method.

    query
    returns

    Definition Classes
    ConnectionPoolConnection
  30. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  31. def take: Future[T]

    Asks for an object from the pool, this object should be returned to the pool when not in use anymore.

    Asks for an object from the pool, this object should be returned to the pool when not in use anymore.

    returns

    Definition Classes
    SingleThreadedAsyncObjectPoolAsyncObjectPool
  32. def toString(): String

    Definition Classes
    AnyRef → Any
  33. def use[A](f: (T) ⇒ Future[A])(implicit executionContext: ExecutionContext): Future[A]

    Retrieve and use an object from the pool for a single computation, returning it when the operation completes.

    Retrieve and use an object from the pool for a single computation, returning it when the operation completes.

    f

    function that uses the object

    returns

    f wrapped with take and giveBack

    Definition Classes
    AsyncObjectPool
  34. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Connection

Inherited from SingleThreadedAsyncObjectPool[T]

Inherited from AsyncObjectPool[T]

Inherited from AnyRef

Inherited from Any

Ungrouped