不要怂,就是干,撸起袖子干!

Commit 5d51e696 by Chris Chew Committed by GitHub

feat(pool): expose maxUses pool config option (#12101)

1 parent a283dc0b
......@@ -138,7 +138,8 @@ class ConnectionManager {
min: config.pool.min,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle,
reapIntervalMillis: config.pool.evict
reapIntervalMillis: config.pool.evict,
maxUses: config.pool.maxUses
});
debug(`pool created with max/min: ${config.pool.max}/${config.pool.min}, no replication`);
......@@ -207,7 +208,8 @@ class ConnectionManager {
min: config.pool.min,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle,
reapIntervalMillis: config.pool.evict
reapIntervalMillis: config.pool.evict,
maxUses: config.pool.maxUses
}),
write: new Pool({
name: 'sequelize:write',
......@@ -223,7 +225,8 @@ class ConnectionManager {
min: config.pool.min,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle,
reapIntervalMillis: config.pool.evict
reapIntervalMillis: config.pool.evict,
maxUses: config.pool.maxUses
})
};
......
......@@ -158,6 +158,7 @@ class Sequelize {
* @param {number} [options.pool.acquire=60000] The maximum time, in milliseconds, that pool will try to get connection before throwing error
* @param {number} [options.pool.evict=1000] The time interval, in milliseconds, after which sequelize-pool will remove idle connections.
* @param {Function} [options.pool.validate] A function that validates a connection. Called with client. The default function checks that client is an object, and that its state is not disconnected
* @param {number} [options.pool.maxUses=Infinity] The number of times a connection can be used before discarding it for a replacement, [`used for eventual cluster rebalancing`](https://github.com/sequelize/sequelize-pool).
* @param {boolean} [options.quoteIdentifiers=true] Set to `false` to make table names and attributes case-insensitive on Postgres and skip double quoting of them. WARNING: Setting this to false may expose vulnerabilities and is not recommended!
* @param {string} [options.transactionType='DEFERRED'] Set the default transaction type. See `Sequelize.Transaction.TYPES` for possible options. Sqlite only.
* @param {string} [options.isolationLevel] Set the default transaction isolation level. See `Sequelize.Transaction.ISOLATION_LEVELS` for possible options.
......
......@@ -109,6 +109,11 @@ export interface PoolOptions {
evict?: number;
/**
* The number of times to use a connection before closing and replacing it. Default is Infinity
*/
maxUses?: number;
/**
* A function that validates a connection. Called with client. The default function checks that client is an
* object, and that its state is not disconnected
*/
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!