PoolSettings class abstract
Store settings for a PostgreSQL connection pool.
Constructors
- PoolSettings({required String databaseUri, String poolName, int minConnections, int maxConnections, int limitConnections, dynamic onOpen(Connection connection)?, void onMaxConnection(int count)?, QueryCallback? onExecute, QueryCallback? onQuery, Duration startTimeout, Duration stopTimeout, Duration establishTimeout, Duration connectionTimeout, Duration idleTimeout, Duration limitTimeout, Duration maxLifetime, Duration? leakDetectionThreshold, bool testConnections, bool restartIfAllConnectionsLeaked, String? applicationName, String? timeZone})
-
factory
Properties
- applicationName → String?
-
The application name is displayed in the pg_stat_activity view.
no setter
- connectionTimeout → Duration
-
When client code calls Pool.connect(), and a
connection does not become available within this time, an error is
returned. Defaults to 30 seconds.
no setter
- databaseUri → String
-
no setter
- establishTimeout → Duration
-
When the pool wants to establish a new database
connection and it is not possible to complete within this time then a
warning will be logged. Defaults to 30 seconds.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- idleTimeout → Duration
-
If a connection has not been used for this ammount of time
and there are more than the minimum number of connections in the pool,
then this connection will be closed. Defaults to 10 minutes.
no setter
- leakDetectionThreshold → Duration?
-
If a connection is not returned to the pool
within this time after being obtained by pool.connect(), the a warning
message will be logged. Defaults to null, off by default. This setting is
useful for tracking down code which leaks connections by forgetting to
call Connection.close() on them.
no setter
- limitConnections → int
-
A soft limit to keep the number of connections below it.
If number of connections exceeds limitConnections,
they'll be removed from the pool as soon as possible
(about a minute after released).
no setter
- limitTimeout → Duration
-
If the number of connections is more than limitConnections,
the establishing of new connections will be slowed down by
waiting the duration specified in limitTimeout. Default: 700ms.
no setter
- maxConnections → int
-
Maximum number of connections. The pool will not exceed
this number of database connections. Defaults to 10.
no setter
- maxLifetime → Duration
-
At the time that a connection is released, if it is older
than this time it will be closed. Defaults to 30 minutes.
no setter
- minConnections → int
-
Minimum number of connections. When the pool is started
this is the number of connections that will initially be started. The pool
will ensure that this number of connections is always running. In typical
production settings, this should be set to be the same size as
maxConnections. Defaults to 5.
no setter
- onExecute → QueryCallback?
-
Callback when Connection.execute is called.
It is useful for detecting unexpected pattern.
For example,
update A set f=null where k=k
is usually an error that@k
shall be used instead. And, it can cause a disaster.no setter - onMaxConnection → void Function(int count)?
-
Callback when detecting the number of DB connections is larger
then the previous maximal number.
no setter
- onOpen → dynamic Function(Connection connection)?
-
Called when the connection is established.
The return value will be stored and passed to onQuery and onExecute.
no setter
- onQuery → QueryCallback?
-
Callback when Connection.query is called.
It is useful for detecting unexpected pattern, such as a SQL pattern
that can perform badly.
no setter
- poolName → String
-
Pool name is used in log messages. It is helpful if there are multiple
connection pools. Defaults to pgpoolX.
no setter
- restartIfAllConnectionsLeaked → bool
-
Once the entire pool is full of leaked
connections, close them all and restart the minimum number of connections.
Defaults to false. This must be used in combination with the leak
detection threshold setting.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- startTimeout → Duration
-
If the pool cannot start within this time then return an
error. Defaults to 30 seconds.
no setter
- stopTimeout → Duration
-
If when stopping connections are not returned to the pool
within this time, then they will be forefully closed. Defaults to 30
seconds.
no setter
- testConnections → bool
-
Perform a simple query to check if a connection is
still valid before returning a connection from pool.connect(). Default is
false.
no setter
- timeZone → String?
-
Care is required when setting the time zone, this is generally not required,
the default, if omitted, is to use the server provided default which will
typically be localtime or sometimes UTC. Setting the time zone to UTC will
override the server provided default and all DateTime objects will be
returned in UTC. In the case where the application server is on a different
host than the database, and the host's DateTimes should be in the host's
localtime, then set this to the host's local time zone name. On linux
systems this can be obtained using:
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited