PartitionedConnectionPool

com.github.mauricio.async.db.pool.PartitionedConnectionPool
class PartitionedConnectionPool[T <: Connection](factory: ObjectFactory[T], configuration: PoolConfiguration, numberOfPartitions: Int, executionContext: ExecutionContext) extends PartitionedAsyncObjectPool[T], Connection

Attributes

Graph
Supertypes
trait Connection
trait AsyncObjectPool[T]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def connect: Future[Connection]

Connects this object to the database. Connection objects are not necessarily created with a connection to the database so you might have to call this method to be able to run queries against it.

Connects this object to the database. Connection objects are not necessarily created with a connection to the database so you might have to call this method to be able to run queries against it.

Attributes

def disconnect: Future[Connection]

Disconnects this object. You should discard this object after calling this method. No more queries will be accepted.

Disconnects this object. You should discard this object after calling this method. No more queries will be accepted.

Attributes

override def inTransaction[A](f: Connection => Future[A])(implicit context: ExecutionContext): Future[A]

Executes an (asynchronous) function within a transaction block. If the function completes successfully, the transaction is committed, otherwise it is aborted.

Executes an (asynchronous) function within a transaction block. If the function completes successfully, the transaction is committed, otherwise it is aborted.

Value parameters

f

operation to execute on this connection

Attributes

Returns

result of f, conditional on transaction operations succeeding

Definition Classes
def isConnected: Boolean

Checks whether we are still connected to the database.

Checks whether we are still connected to the database.

Attributes

def sendPreparedStatement(query: String, values: Seq[Any]): Future[QueryResult]

Sends a prepared statement to the database. Prepared statements are special statements that are pre-compiled by the database to run faster, they also allow you to avoid SQL injection attacks by not having to concatenate strings from possibly unsafe sources (like users) and sending them directy to the database.

Sends a prepared statement to the database. Prepared statements are special statements that are pre-compiled by the database to run faster, they also allow you to avoid SQL injection attacks by not having to concatenate strings from possibly unsafe sources (like users) and sending them directy to the database.

When sending a prepared statement, you can insert ? signs in your statement and then provide values at the method call 'values' parameter, as in:

 connection.sendPreparedStatement( "SELECT * FROM users WHERE users.login = ?", Array( "john-doe" ) )

As you are using the ? as the placeholder for the value, you don't have to perform any kind of manipulation to the value, just provide it as is and the database will clean it up. You must provide as many parameters as you have provided placeholders, so, if your query is as "INSERT INTO users (login,email) VALUES (?,?)" you have to provide an array with at least two values, as in:

 Array("john-doe", "[email protected]")

You can still use this method if your statement doesn't take any parameters, the default is an empty collection.

Attributes

def sendQuery(query: String): Future[QueryResult]

Sends a statement to the database. The statement can be anything your database can execute. Not all statements will return a collection of rows, so check the returned object if there are rows available.

Sends a statement to the database. The statement can be anything your database can execute. Not all statements will return a collection of rows, so check the returned object if there are rows available.

Attributes

Inherited methods

def availables: Iterable[T]

Attributes

Inherited from:
PartitionedAsyncObjectPool
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.

Attributes

Inherited from:
PartitionedAsyncObjectPool
def giveBack(item: T): Future[AsyncObjectPool[T]]

Returns an object taken from the pool back to it. This object will become available for another client to use. If the object is invalid or can not be reused for some reason the scala.concurrent.Future returned will contain the error that prevented this object of being added back to the pool. The object is then discarded from the pool.

Returns an object taken from the pool back to it. This object will become available for another client to use. If the object is invalid or can not be reused for some reason the scala.concurrent.Future returned will contain the error that prevented this object of being added back to the pool. The object is then discarded from the pool.

Attributes

Inherited from:
PartitionedAsyncObjectPool
def inUse: Iterable[T]

Attributes

Inherited from:
PartitionedAsyncObjectPool
protected def isClosed: Boolean

Attributes

Inherited from:
PartitionedAsyncObjectPool
def queued: Iterable[Promise[T]]

Attributes

Inherited from:
PartitionedAsyncObjectPool
def take: Future[T]

Returns an object from the pool to the callee with the returned future. If the pool can not create or enqueue requests it will fill the returned scala.concurrent.Future with an com.github.mauricio.async.db.pool.PoolExhaustedException.

Returns an object from the pool to the callee with the returned future. If the pool can not create or enqueue requests it will fill the returned scala.concurrent.Future with an com.github.mauricio.async.db.pool.PoolExhaustedException.

Attributes

Returns

future that will eventually return a usable pool object.

Inherited from:
PartitionedAsyncObjectPool
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.

Value parameters

f

function that uses the object

Attributes

Returns

f wrapped with take and giveBack

Inherited from:
AsyncObjectPool