123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- "use strict";
- const PoolDefaults = require("./PoolDefaults");
- class PoolOptions {
-
- constructor(opts) {
- const poolDefaults = new PoolDefaults();
- opts = opts || {};
- this.fifo = typeof opts.fifo === "boolean" ? opts.fifo : poolDefaults.fifo;
- this.priorityRange = opts.priorityRange || poolDefaults.priorityRange;
- this.testOnBorrow =
- typeof opts.testOnBorrow === "boolean"
- ? opts.testOnBorrow
- : poolDefaults.testOnBorrow;
- this.testOnReturn =
- typeof opts.testOnReturn === "boolean"
- ? opts.testOnReturn
- : poolDefaults.testOnReturn;
- this.autostart =
- typeof opts.autostart === "boolean"
- ? opts.autostart
- : poolDefaults.autostart;
- if (opts.acquireTimeoutMillis) {
-
- this.acquireTimeoutMillis = parseInt(opts.acquireTimeoutMillis, 10);
- }
- if (opts.destroyTimeoutMillis) {
-
- this.destroyTimeoutMillis = parseInt(opts.destroyTimeoutMillis, 10);
- }
- if (opts.maxWaitingClients !== undefined) {
-
- this.maxWaitingClients = parseInt(opts.maxWaitingClients, 10);
- }
-
- this.max = parseInt(opts.max, 10);
-
- this.min = parseInt(opts.min, 10);
- this.max = Math.max(isNaN(this.max) ? 1 : this.max, 1);
- this.min = Math.min(isNaN(this.min) ? 0 : this.min, this.max);
- this.evictionRunIntervalMillis =
- opts.evictionRunIntervalMillis || poolDefaults.evictionRunIntervalMillis;
- this.numTestsPerEvictionRun =
- opts.numTestsPerEvictionRun || poolDefaults.numTestsPerEvictionRun;
- this.softIdleTimeoutMillis =
- opts.softIdleTimeoutMillis || poolDefaults.softIdleTimeoutMillis;
- this.idleTimeoutMillis =
- opts.idleTimeoutMillis || poolDefaults.idleTimeoutMillis;
- this.Promise = opts.Promise != null ? opts.Promise : poolDefaults.Promise;
- }
- }
- module.exports = PoolOptions;
|