PoolConfig.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. var ConnectionConfig = require('./ConnectionConfig');
  2. module.exports = PoolConfig;
  3. function PoolConfig(options) {
  4. if (typeof options === 'string') {
  5. options = ConnectionConfig.parseUrl(options);
  6. }
  7. this.acquireTimeout = (options.acquireTimeout === undefined)
  8. ? 10 * 1000
  9. : Number(options.acquireTimeout);
  10. this.connectionConfig = new ConnectionConfig(options);
  11. this.waitForConnections = (options.waitForConnections === undefined)
  12. ? true
  13. : Boolean(options.waitForConnections);
  14. this.connectionLimit = (options.connectionLimit === undefined)
  15. ? 10
  16. : Number(options.connectionLimit);
  17. this.queueLimit = (options.queueLimit === undefined)
  18. ? 0
  19. : Number(options.queueLimit);
  20. }
  21. PoolConfig.prototype.newConnectionConfig = function newConnectionConfig() {
  22. var connectionConfig = new ConnectionConfig(this.connectionConfig);
  23. connectionConfig.clientFlags = this.connectionConfig.clientFlags;
  24. connectionConfig.maxPacketSize = this.connectionConfig.maxPacketSize;
  25. return connectionConfig;
  26. };