API/api.medcify.app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js.map

8 lines
16 KiB
Plaintext
Raw Normal View History

2022-09-26 06:11:44 +00:00
{
"version": 3,
"sources": ["../../../src/dialects/abstract/connection-manager.js"],
"sourcesContent": ["'use strict';\n\nconst { Pool, TimeoutError } = require('sequelize-pool');\nconst _ = require('lodash');\nconst semver = require('semver');\nconst errors = require('../../errors');\nconst { logger } = require('../../utils/logger');\nconst deprecations = require('../../utils/deprecations');\nconst debug = logger.debugContext('pool');\n\n/**\n * Abstract Connection Manager\n *\n * Connection manager which handles pooling & replication.\n * Uses sequelize-pool for pooling\n *\n * @private\n */\nclass ConnectionManager {\n constructor(dialect, sequelize) {\n const config = _.cloneDeep(sequelize.config);\n\n this.sequelize = sequelize;\n this.config = config;\n this.dialect = dialect;\n this.versionPromise = null;\n this.dialectName = this.sequelize.options.dialect;\n\n if (config.pool === false) {\n throw new Error('Support for pool:false was removed in v4.0');\n }\n\n config.pool = _.defaults(config.pool || {}, {\n max: 5,\n min: 0,\n idle: 10000,\n acquire: 60000,\n evict: 1000,\n validate: this._validate.bind(this)\n });\n\n this.initPools();\n }\n\n refreshTypeParser(dataTypes) {\n _.each(dataTypes, dataType => {\n if (Object.prototype.hasOwnProperty.call(dataType, 'parse')) {\n if (dataType.types[this.dialectName]) {\n this._refreshTypeParser(dataType);\n } else {\n throw new Error(`Parse function not supported for type ${dataType.key} in dialect ${this.dialectName}`);\n }\n }\n });\n }\n\n /**\n * Try to load dialect module from various configured options.\n * Priority goes like dialectModulePath > dialectModule > require(default)\n *\n * @param {string} moduleName Name of dialect module to lookup\n *\n * @private\n * @returns {object}\n */\n _loadDialectModule(moduleName) {\n try {\n if (this.sequelize.config.dialectModulePath) {\n return require(this.sequelize.config.dialectModulePath);\n }\n if (this.sequelize.config.dialectModule) {\n return this.sequelize.config.dialectModule;\n }\n return require(moduleName);\n\n } catch (err) {\n if (err.code === 'MODULE_NOT_FOUND') {\n if (this.sequelize.config.dialectModulePath) {\n throw new Error(`Unable to find dialect at ${this.sequelize.config.dialectModulePath}`);\n }\n throw new Error(`Please install ${moduleName} package manually`);\n }\n\n throw err;\n }\n }\n\n /**\n * Handler which executes on process exit or connection manager shutdown\n *\n * @private\n * @returns {Promise}\n */\n async _onProcessExit() {\n if (!this.pool) {\n return;\n }\n\n await this.pool.drain();\n debug('connection drain due to process exit');\n\n return await this.pool.destroyAllNow();\n }\n\n /**\n * Drain the pool and close it permanently\n *\n * @returns {Promise}\n */\n async close() {\n // Mark close of pool\n this.getConnection = async function getConnection() {\n throw new Error('ConnectionManager.getConnection was called after the connection manager was closed!');\n };\n\n return await this._onProcessExit();\n }\n\n /**\n * Initialize connection pool. By default pool autostart is set to false, so no connection will be\n * be created unless `pool.acquire` is called.\n */\n initPools() {\n const config = this.config;\n\n if (!config.replication) {\n this.pool = new Pool({\n name: 'sequelize',\n create: () => this._connect(config),\n destroy: async connection => {\n const result = await this._disconnect(connection);\n debug('connection destroy');\n return result;\n },\n validate: config.pool.validate,\n max: config.pool.max,\n min: config.pool.min,\n acquireTimeoutMillis: config.pool.acquire,\n idleTimeoutMillis: config.pool.idle,\n reapIntervalMillis: config.pool.evict,\n maxUses: config.pool.maxUses\n });\n\n debug(`pool created with max
"mappings": ";AAEA,MAAM,EAAE,MAAM,iBAAiB,QAAQ;AACvC,MAAM,IAAI,QAAQ;AAClB,MAAM,SAAS,QAAQ;AACvB,MAAM,SAAS,QAAQ;AACvB,MAAM,EAAE,WAAW,QAAQ;AAC3B,MAAM,eAAe,QAAQ;AAC7B,MAAM,QAAQ,OAAO,aAAa;AAUlC,wBAAwB;AAAA,EACtB,YAAY,SAAS,WAAW;AAC9B,UAAM,SAAS,EAAE,UAAU,UAAU;AAErC,SAAK,YAAY;AACjB,SAAK,SAAS;AACd,SAAK,UAAU;AACf,SAAK,iBAAiB;AACtB,SAAK,cAAc,KAAK,UAAU,QAAQ;AAE1C,QAAI,OAAO,SAAS,OAAO;AACzB,YAAM,IAAI,MAAM;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