Skip to content

Commit

Permalink
Merge pull request #13 from jeremydaly/v1.2.0
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
jeremydaly authored Dec 7, 2018
2 parents 3dcbb86 + 27940bd commit 3659f6c
Show file tree
Hide file tree
Showing 4 changed files with 320 additions and 207 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Serverless MySQL

[![npm](https://img.shields.io/npm/v/serverless-mysql.svg)](https://www.npmjs.com/package/serverless-mysql)
[![npm](https://img.shields.io/npm/l/serverless-mysql.svg)](https://www.npmjs.com/package/serverless-mysql)

### A module for managing MySQL connections at *serverless* scale.

Serverless MySQL is a wrapper for Doug Wilson's amazing **[mysql](https://github.com/mysqljs/mysql)** Node.js module. Normally, using the `mysql` module with Node apps would be just fine. However, serverless functions (like AWS Lambda, Google Cloud Functions, and Azure Functions) scale almost infinitely by creating separate instances for each concurrent user. This is a **MAJOR PROBLEM** for RDBS solutions like MySQL, because available connections can be quickly maxed out by competing functions. Not anymore. 😀
Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,11 @@ const query = async function(...args) {
client.destroy() // destroy connection on timeout
resetClient() // reset the client
reject(err) // reject the promise with the error
} else if (err && /^PROTOCOL_ENQUEUE_AFTER_/.test(err.code)) {
resetClient() // reset the client
return resolve(query(...args)) // attempt the query again
} else if (err) {
if (this.rollback) {
if (this && this.rollback) {
await query('ROLLBACK')
this.rollback(err)
}
Expand Down
Loading

0 comments on commit 3659f6c

Please sign in to comment.