@7digital/mysql2-timeout
A wrapper for mysql2 connection pool query to support acquireTimeout and queryTimeout options
Last updated a year ago by c24w .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @7digital/mysql2-timeout 
SYNC missed versions from official npm registry.

MySQL2 Timeout

7digital


Travis CI npm Node.js Version

A wrapper for mysql2 connection pool query to support acquireTimeout and queryTimeout options.

Installation

npm install mysql2 @7digital/mysql2-timeout

Usage

Just use this instead of mysql2 and call connect passing queryTimeout and acquireTimeout millisecond values. If not passed, each will default to 10 seconds. All other options will be passed directly to mysql2.

If connection aquisition times out, a DatabaseTimeout error will be thrown.

If querying times out, it will

  • kill the connection
  • attempt to kill the outstanding query in the background
  • throw a DatabaseTimeout error

This only exposes the mysql2 connection pool promise interface.

Example

const database = require('@7digital/mysql2-timeout');

async function main() {
  const db = await database.connect({
    host: 'localhost',
    user: 'root',
    database: 'test',
    queryTimeout: 5000,
    acquireTimeout: 2000
  });

  await db.query('SELECT 1');
}

Developing

docker-compose run test

Runs the tests once.

docker-compose run watch

Runs the tests when the source or tests change.

Current Tags

  • 2.0.0                                ...           latest (a year ago)

4 Versions

  • 2.0.0                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Downloads
Today 0
This Week 0
This Month 4
Last Day 0
Last Week 4
Last Month 8
Dependencies (0)
None
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |