mysql2 3.13.0 → 3.14.0
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/lib/pool_cluster.js +18 -14
- package/package.json +1 -1
package/lib/pool_cluster.js
CHANGED
|
@@ -37,6 +37,18 @@ const getMonotonicMilliseconds = function () {
|
|
|
37
37
|
return Math.floor(ms);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
const patternRegExp = function (pattern) {
|
|
41
|
+
if (pattern instanceof RegExp) {
|
|
42
|
+
return pattern;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const source = pattern
|
|
46
|
+
.replace(/([.+?^=!:${}()|[\]/\\])/g, '\\$1')
|
|
47
|
+
.replace(/\*/g, '.*');
|
|
48
|
+
|
|
49
|
+
return new RegExp(`^${source}$`);
|
|
50
|
+
};
|
|
51
|
+
|
|
40
52
|
class PoolNamespace {
|
|
41
53
|
constructor(cluster, pattern, selector) {
|
|
42
54
|
this._cluster = cluster;
|
|
@@ -256,20 +268,12 @@ class PoolCluster extends EventEmitter {
|
|
|
256
268
|
let currentTime = 0;
|
|
257
269
|
let foundNodeIds = this._findCaches[pattern];
|
|
258
270
|
|
|
259
|
-
if (
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
foundNodeIds = [pattern];
|
|
266
|
-
} else {
|
|
267
|
-
// wild matching
|
|
268
|
-
const keyword = pattern.substring(pattern.length - 1, 0);
|
|
269
|
-
foundNodeIds = this._serviceableNodeIds.filter((id) =>
|
|
270
|
-
id.startsWith(keyword)
|
|
271
|
-
);
|
|
272
|
-
}
|
|
271
|
+
if (foundNodeIds === undefined) {
|
|
272
|
+
const expression = patternRegExp(pattern);
|
|
273
|
+
|
|
274
|
+
foundNodeIds = this._serviceableNodeIds.filter((id) =>
|
|
275
|
+
id.match(expression)
|
|
276
|
+
);
|
|
273
277
|
}
|
|
274
278
|
|
|
275
279
|
this._findCaches[pattern] = foundNodeIds;
|
package/package.json
CHANGED