Pool<L> class
abstract
A connection pool that may select endpoints based on the requested locality
L
of the data.
A data locality can be an arbitrary value that the pool's EndpointSelector understands, and may return a connection based on, e.g:
- an action, which applies to different database or user,
- a tenant, which may be specified for multi-tenant applications,
- a table and key, which may be specified for distributed databases (e.g. CockroachDB) for selecting the node that is the leader for the specified data range.
- a primary/replica status, whic may be specified for cases where stale or read-only data is acceptable
- Implemented types
Constructors
-
Pool.withEndpoints(List<
Endpoint> endpoints, {PoolSettings? settings}) -
Creates a connection pool from a fixed list of endpoints.
factory
-
Pool.withSelector(EndpointSelector<
L> selector, {PoolSettings? settings}) -
factory
Properties
-
closed
→ Future<
void> -
A future that completes when isOpen turns false.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isOpen → bool
-
Whether this connection is currently open.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → Future< void> -
Closes this session, cleaning up resources and forbiding further calls to
prepare and execute.
inherited
-
execute(
Object query, {Object? parameters, bool ignoreRows = false, QueryMode? queryMode, Duration? timeout}) → Future< Result> -
Executes the
query
with the givenparameters
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prepare(
Object query) → Future< Statement> -
Prepares a reusable statement from a
query
.inherited -
run<
R> (Future< R> fn(Session session), {SessionSettings? settings, L? locality}) → Future<R> -
Obtains a Session capable of running statements and calls
fn
with it.override -
runTx<
R> (Future< R> fn(TxSession session), {TransactionSettings? settings, L? locality}) → Future<R> -
Obtains a Session running in a transaction and calls
fn
with it.override -
toString(
) → String -
A string representation of this object.
inherited
-
withConnection<
R> (Future< R> fn(Connection connection), {ConnectionSettings? settings, L? locality}) → Future<R> -
Acquires a connection from this pool, opening a new one if necessary, and
calls
fn
with it.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited