Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.pool[connection.queryType].destroy(connection);
debug('connection destroy');
},
destroyAllNow: () => {
return Promise.join(
this.pool.read.destroyAllNow(),
this.pool.write.destroyAllNow()
).tap(() => { debug('all connections destroyed'); });
},
drain: () => {
return Promise.join(
this.pool.write.drain(),
this.pool.read.drain()
);
},
read: new Pool({
name: 'sequelize:read',
create: () => {
// round robin config
const nextRead = reads++ % config.replication.read.length;
return this._connect(config.replication.read[nextRead]).tap(connection => {
connection.queryType = 'read';
});
},
destroy: connection => this._disconnect(connection),
validate: config.pool.validate,
max: config.pool.max,
min: config.pool.min,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle,
reapIntervalMillis: config.pool.evict
}),
this.pool[connection.queryType].destroy(connection);
debug('connection destroy');
},
destroyAllNow: () => {
return Promise.join(
this.pool.read.destroyAllNow(),
this.pool.write.destroyAllNow()
).tap(() => { debug('all connections destroyed'); });
},
drain: () => {
return Promise.join(
this.pool.write.drain(),
this.pool.read.drain()
);
},
read: new Pool({
name: 'sequelize:read',
create: () => {
// round robin config
const nextRead = reads++ % config.replication.read.length;
return this._connect(config.replication.read[nextRead]).tap(connection => {
connection.queryType = 'read';
});
},
destroy: connection => this._disconnect(connection),
validate: config.pool.validate,
max: config.pool.max,
min: config.pool.min,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle,
reapIntervalMillis: config.pool.evict
}),
create: () => {
// round robin config
const nextRead = reads++ % config.replication.read.length;
return this._connect(config.replication.read[nextRead]).tap(connection => {
connection.queryType = 'read';
});
},
destroy: connection => this._disconnect(connection),
validate: config.pool.validate,
max: config.pool.max,
min: config.pool.min,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle,
reapIntervalMillis: config.pool.evict
}),
write: new Pool({
name: 'sequelize:write',
create: () => {
return this._connect(config.replication.write).tap(connection => {
connection.queryType = 'write';
});
},
destroy: connection => this._disconnect(connection),
validate: config.pool.validate,
max: config.pool.max,
min: config.pool.min,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle,
reapIntervalMillis: config.pool.evict
})
};
create: () => {
// round robin config
const nextRead = reads++ % config.replication.read.length;
return this._connect(config.replication.read[nextRead]).tap(connection => {
connection.queryType = 'read';
});
},
destroy: connection => this._disconnect(connection),
validate: config.pool.validate,
max: config.pool.max,
min: config.pool.min,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle,
reapIntervalMillis: config.pool.evict
}),
write: new Pool({
name: 'sequelize:write',
create: () => {
return this._connect(config.replication.write).tap(connection => {
connection.queryType = 'write';
});
},
destroy: connection => this._disconnect(connection),
validate: config.pool.validate,
max: config.pool.max,
min: config.pool.min,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle,
reapIntervalMillis: config.pool.evict
})
};
initPools() {
const config = this.config;
if (!config.replication) {
this.pool = new Pool({
name: 'sequelize',
create: () => this._connect(config),
destroy: connection => {
return this._disconnect(connection)
.tap(() => { debug('connection destroy'); });
},
validate: config.pool.validate,
max: config.pool.max,
min: config.pool.min,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle,
reapIntervalMillis: config.pool.evict
});
debug(`pool created with max/min: ${config.pool.max}/${config.pool.min}, no replication`);
initPools() {
const config = this.config;
if (!config.replication) {
this.pool = new Pool({
name: 'sequelize',
create: () => this._connect(config),
destroy: connection => {
return this._disconnect(connection)
.tap(() => { debug('connection destroy'); });
},
validate: config.pool.validate,
max: config.pool.max,
min: config.pool.min,
acquireTimeoutMillis: config.pool.acquire,
idleTimeoutMillis: config.pool.idle,
reapIntervalMillis: config.pool.evict
});
debug(`pool created with max/min: ${config.pool.max}/${config.pool.min}, no replication`);