Class

com.github.mauricio.async.db.pool

ConnectionPool

Related Doc: package pool

Permalink

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
Visibility
  1. Public
  2. All

Instance Constructors

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

    Permalink

Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def availables: Traversable[T]

    Permalink
  6. def clone(): AnyRef

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

    Permalink

    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.

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

    Permalink

    Always returns an empty map.

    Always returns an empty map.

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

    Permalink

    Closes the pool, you should discard the object.

    Closes the pool, you should discard the object.

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

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

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

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

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

    Permalink

    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.

    Definition Classes
    SingleThreadedAsyncObjectPoolAsyncObjectPool
  15. def hashCode(): Int

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

    Permalink

    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
  17. def inUse: Traversable[T]

    Permalink
  18. def isClosed: Boolean

    Permalink
  19. def isConnected: Boolean

    Permalink

    Checks whether we are still connected to the database.

    Checks whether we are still connected to the database.

    Definition Classes
    ConnectionPoolConnection
  20. def isFull: Boolean

    Permalink
  21. final def isInstanceOf[T0]: Boolean

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

    Permalink
    Definition Classes
    AnyRef
  23. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit

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

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink
    Definition Classes
    AnyRef
  29. def take: Future[T]

    Permalink

    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.

    Definition Classes
    SingleThreadedAsyncObjectPoolAsyncObjectPool
  30. def toString(): String

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

    Permalink

    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
  32. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Connection

Inherited from SingleThreadedAsyncObjectPool[T]

Inherited from AsyncObjectPool[T]

Inherited from AnyRef

Inherited from Any

Ungrouped