MCPcopy
hub / github.com/sequelize/sequelize / ConnectionManager

Class ConnectionManager

src/dialects/abstract/connection-manager.js:19–364  ·  view source on GitHub ↗

* Abstract Connection Manager * * Connection manager which handles pooling & replication. * Uses sequelize-pool for pooling * * @private

Source from the content-addressed store, hash-verified

17 * @private
18 */
19class ConnectionManager {
20 constructor(dialect, sequelize) {
21 const config = _.cloneDeep(sequelize.config);
22
23 this.sequelize = sequelize;
24 this.config = config;
25 this.dialect = dialect;
26 this.versionPromise = null;
27 this.dialectName = this.sequelize.options.dialect;
28
29 if (config.pool === false) {
30 throw new Error('Support for pool:false was removed in v4.0');
31 }
32
33 config.pool = _.defaults(config.pool || {}, {
34 max: 5,
35 min: 0,
36 idle: 10000,
37 acquire: 60000,
38 evict: 1000,
39 validate: this._validate.bind(this)
40 });
41
42 this.initPools();
43 }
44
45 refreshTypeParser(dataTypes) {
46 _.each(dataTypes, dataType => {
47 if (Object.prototype.hasOwnProperty.call(dataType, 'parse')) {
48 if (dataType.types[this.dialectName]) {
49 this._refreshTypeParser(dataType);
50 } else {
51 throw new Error(`Parse function not supported for type ${dataType.key} in dialect ${this.dialectName}`);
52 }
53 }
54 });
55 }
56
57 /**
58 * Try to load dialect module from various configured options.
59 * Priority goes like dialectModulePath > dialectModule > require(default)
60 *
61 * @param {string} moduleName Name of dialect module to lookup
62 *
63 * @private
64 * @returns {object}
65 */
66 _loadDialectModule(moduleName) {
67 try {
68 if (this.sequelize.config.dialectModulePath) {
69 return require(this.sequelize.config.dialectModulePath);
70 }
71 if (this.sequelize.config.dialectModule) {
72 return this.sequelize.config.dialectModule;
73 }
74 return require(moduleName);
75
76 } catch (err) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected