const waitForMongo = async function ({ url }) { if (!url) { throw new Error('Url is missing.'); } await retry(async () => { /* eslint-disable id-length */ const client = await MongoClient.connect(url, { w: 1, useNewUrlParser: true }); /* eslint-enable id-length */ await client.close(); }); }
async getDatabase () { const database = await retry(async () => { const connection = await this.pool.getConnection(); return connection; }); return database; }
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 getDatabase () { const database = await retry(async () => { const connection = await this.pool.acquire().promise; return connection; }); return database; }
async _connectWithRetry(configWithListener) { try { await retry( async _bail => { // If anything throws, we retry this.connection = await imaps.connect(configWithListener) this.connection.on('error', err => { // We assume that the app will be restarted after a crash. console.error( 'got fatal error during imap operation, stop app.', err ) this.emit('error', err) }) await this.connection.openBox('INBOX') debug('connected to imap') }, { retries: 5 } ) } catch (error) { console.error('can not connect, even with retry, stop app', error) throw error } }
this.client = await retry(async () => { const connection = await MongoClient.connect(url, { w: 1, useNewUrlParser: true });
await retry(async () => { await new Promise((resolve, reject) => { connection = new Connection(config);
await retry(async () => { await connection.query(` CREATE TABLE IF NOT EXISTS "${this.namespace}_events" (
async getDatabase () { const database = await retry(async () => { const connection = await this.pool.connect(); return connection; }); return database; }
const waitForMaria = async function ({ url }) { if (!url) { throw new Error('Url is missing.'); } const { host, port, user, password, database } = new DsnParser(url).getParts(); const pool = mysql.createPool({ host, port, user, password, database }); await retry(async () => { const connection = await pool.getConnection(); await connection.release(); }); await pool.end(); }
async getDatabase () { const database = await retry(async () => { const connection = await this.pool.getConnection(); return connection; }); return database; }
const waitForMysql = async function ({ url }) { if (!url) { throw new Error('Url is missing.'); } const { host, port, user, password, database } = new DsnParser(url).getParts(); const pool = mysql.createPool({ host, port, user, password, database }); await retry(async () => { const connection = await pool.getConnection(); await connection.release(); }); await pool.end(); }