PoolSettings class Null safety

Store settings for a PostgreSQL connection pool.

Constructors

PoolSettings({required String databaseUri, String poolName, int minConnections, int maxConnections, int limitConnections, void onMaxConnection(int count)?, void onExecute(String sql, dynamic values)?, void onQuery(String sql, dynamic values)?, 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.
read-only
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.
read-only
databaseUri String
read-only
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.
read-only
hashCode int
The hash code for this object.
read-onlyinherited
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.
read-only
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.
read-only
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).
read-only
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.
read-only
maxConnections int
Maximum number of connections. The pool will not exceed this number of database connections. Defaults to 10.
read-only
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.
read-only
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.
read-only
onExecute → (void Function?(String sql, dynamic values)?)
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.
read-only
onMaxConnection → (void Function?(int count)?)
Callback when detecting the number of DB connections is larger then the previous maximal number.
read-only
onQuery → (void Function?(String sql, dynamic values)?)
Callback when Connection.query is called. It is useful for detecting unexpected pattern, such as a SQL pattern that can perform badly.
read-only
poolName String
Pool name is used in log messages. It is helpful if there are multiple connection pools. Defaults to pgpoolX.
read-only
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.
read-only
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
startTimeout Duration
If the pool cannot start within this time then return an error. Defaults to 30 seconds.
read-only
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.
read-only
testConnections bool
Perform a simple query to check if a connection is still valid before returning a connection from pool.connect(). Default is false.
read-only
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:
read-only

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited