release() { return this.pool.end(); }
// No need for a server, let's just spin up the schema builder (async (): Promise<void> => { const pgPool = new Pool(pgConfig); pgPool.on('error', err => { // tslint:disable-next-line no-console console.error('PostgreSQL client generated error: ', err.message); }); const { getGraphQLSchema } = getPostgraphileSchemaBuilder(pgPool, schemas, postgraphileOptions); await getGraphQLSchema(); if (!watchPg) { await pgPool.end(); } })().then(null, e => { console.error('Error occurred!'); console.error(e); process.exit(1); });
// tslint:disable-next-line no-any function toPgPool(poolOrConfig: any): { pgPool: Pool; release: null | (() => void) } { if (quacksLikePgPool(poolOrConfig)) { // If it is already a `Pool`, just use it. return { pgPool: poolOrConfig, release: null }; } if (typeof poolOrConfig === 'string') { // If it is a string, let us parse it to get a config to create a `Pool`. const pgPool = new Pool({ connectionString: poolOrConfig }); return { pgPool, release: () => pgPool.end() }; } else if (!poolOrConfig) { // Use an empty config and let the defaults take over. const pgPool = new Pool({}); return { pgPool, release: () => pgPool.end() }; } else if (isPlainObject(poolOrConfig)) { // The user handed over a configuration object, pass it through const pgPool = new Pool(poolOrConfig); return { pgPool, release: () => pgPool.end() }; } else { throw new Error('Invalid connection string / Pool '); } }
// Close PostgresProvider // Returns: <Promise> async close() { if (!this.pool) { return; } await this.pool.end(); this.pool = null; this.active = false; }
pgHandler.initialize() .then(migrateHits) .then(migrateErrors) .then(async () => console.log('*** transfer completed ***')) .then(async () => pgDb.end()) .then(async () => pgHandler.disconnect()) .then(async () => console.log('done'))
const createPoolConnection = (conf: any): DBConnectionsPool => { const pool: Pool = new Pool(conf); return { query(q) { return pool.query(q); }, connect() { return pool.connect(); }, stop() { return pool.end(); } }; }
pgpool.on('error', (e, c) => { console.log('pgpool error: ' + e); pgpool.end(); setTimeout(function () { pgpool = new pg.Pool(db_config); }, 100); })
const waitForPostgres = async function ({ url }) { if (!url) { throw new Error('Url is missing.'); } const { host, port, user, password, database } = new DsnParser(url).getParts(); const pool = new pg.Pool({ host, port, user, password, database }); await retry(async () => { const connection = await pool.connect(); connection.release(); }); await pool.end(); }
async close () { if (!this.pool.ending) { await this.pool.end() this.opened = false } }
end () { this._pool.end(); }
async destroy() { this.pool.end(); this.poll = null; }
async destroy() { this.pool.end(); this.poll = null; }