Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pool): Expose the recently added maxUses pool config option #12101

Merged
merged 2 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/dialects/abstract/connection-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down Expand Up @@ -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',
Expand All @@ -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
})
};

Expand Down
1 change: 1 addition & 0 deletions lib/sequelize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions types/lib/sequelize.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,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
Expand Down