mysql2 3.3.1 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/lib/connection.js +4 -3
- package/lib/connection_config.js +1 -1
- package/package.json +1 -1
- package/typings/mysql/lib/Pool.d.ts +2 -3
package/README.md
CHANGED
|
@@ -134,7 +134,9 @@ const pool = mysql.createPool({
|
|
|
134
134
|
connectionLimit: 10,
|
|
135
135
|
maxIdle: 10, // max idle connections, the default value is the same as `connectionLimit`
|
|
136
136
|
idleTimeout: 60000, // idle connections timeout, in milliseconds, the default value 60000
|
|
137
|
-
queueLimit: 0
|
|
137
|
+
queueLimit: 0,
|
|
138
|
+
enableKeepAlive: true,
|
|
139
|
+
keepAliveInitialDelay: 0
|
|
138
140
|
});
|
|
139
141
|
```
|
|
140
142
|
The pool does not create all connections upfront but creates them on demand until the connection limit is reached.
|
package/lib/connection.js
CHANGED
|
@@ -52,9 +52,10 @@ class Connection extends EventEmitter {
|
|
|
52
52
|
opts.config.host
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
// Optionally enable keep-alive on the socket.
|
|
56
|
+
if (this.config.enableKeepAlive) {
|
|
57
|
+
this.stream.setKeepAlive(true, this.config.keepAliveInitialDelay);
|
|
58
|
+
}
|
|
58
59
|
|
|
59
60
|
// Enable TCP_NODELAY flag. This is needed so that the network packets
|
|
60
61
|
// are sent immediately to the server
|
package/lib/connection_config.js
CHANGED
|
@@ -115,7 +115,7 @@ class ConnectionConfig {
|
|
|
115
115
|
this.debug = options.debug;
|
|
116
116
|
this.trace = options.trace !== false;
|
|
117
117
|
this.stringifyObjects = options.stringifyObjects || false;
|
|
118
|
-
this.enableKeepAlive =
|
|
118
|
+
this.enableKeepAlive = options.enableKeepAlive !== false;
|
|
119
119
|
this.keepAliveInitialDelay = options.keepAliveInitialDelay || 0;
|
|
120
120
|
if (
|
|
121
121
|
options.timezone &&
|
package/package.json
CHANGED
|
@@ -44,13 +44,12 @@ declare namespace Pool {
|
|
|
44
44
|
queueLimit?: number;
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* Enable keep-alive on the socket.
|
|
48
|
-
* user can enable it and supply an initial delay.
|
|
47
|
+
* Enable keep-alive on the socket. (Default: true)
|
|
49
48
|
*/
|
|
50
49
|
enableKeepAlive?: boolean;
|
|
51
50
|
|
|
52
51
|
/**
|
|
53
|
-
* If keep-alive is enabled users can supply an initial delay.
|
|
52
|
+
* If keep-alive is enabled users can supply an initial delay. (Default: 0)
|
|
54
53
|
*/
|
|
55
54
|
keepAliveInitialDelay?: number;
|
|
56
55
|
}
|