@cubejs-backend/shared 1.6.9 → 1.6.10
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/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/pool.d.ts +35 -0
- package/dist/src/pool.d.ts.map +1 -0
- package/dist/src/pool.js +98 -0
- package/dist/src/pool.js.map +1 -0
- package/package.json +4 -3
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,kBAAkB,GACnB,MAAM,OAAO,CAAC;AACf,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,kBAAkB,GACnB,MAAM,OAAO,CAAC;AACf,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -42,4 +42,5 @@ __exportStar(require("./decorators"), exports);
|
|
|
42
42
|
__exportStar(require("./PerfTracker"), exports);
|
|
43
43
|
__exportStar(require("./disposedProxy"), exports);
|
|
44
44
|
__exportStar(require("./logger"), exports);
|
|
45
|
+
__exportStar(require("./pool"), exports);
|
|
45
46
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6BAMe;AALb,6FAAA,MAAM,OAAA;AACN,uGAAA,gBAAgB,OAAA;AAChB,sGAAA,eAAe,OAAA;AACf,oGAAA,aAAa,OAAA;AACb,yGAAA,kBAAkB,OAAA;AAEpB,0CAAwB;AACxB,4CAA0B;AAC1B,0CAAwB;AACxB,2CAAyB;AACzB,6CAA2B;AAC3B,4CAA0B;AAC1B,4CAA0B;AAC1B,+CAA6B;AAC7B,iDAA+B;AAC/B,iDAA+B;AAC/B,+CAA6B;AAC7B,wCAAsB;AACtB,0CAAwB;AACxB,yCAAuB;AACvB,4CAA0B;AAC1B,6CAA2B;AAC3B,mDAAiC;AACjC,+CAA6B;AAC7B,gDAA8B;AAC9B,kDAAgC;AAChC,2CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6BAMe;AALb,6FAAA,MAAM,OAAA;AACN,uGAAA,gBAAgB,OAAA;AAChB,sGAAA,eAAe,OAAA;AACf,oGAAA,aAAa,OAAA;AACb,yGAAA,kBAAkB,OAAA;AAEpB,0CAAwB;AACxB,4CAA0B;AAC1B,0CAAwB;AACxB,2CAAyB;AACzB,6CAA2B;AAC3B,4CAA0B;AAC1B,4CAA0B;AAC1B,+CAA6B;AAC7B,iDAA+B;AAC/B,iDAA+B;AAC/B,+CAA6B;AAC7B,wCAAsB;AACtB,0CAAwB;AACxB,yCAAuB;AACvB,4CAA0B;AAC1B,6CAA2B;AAC3B,mDAAiC;AACjC,+CAA6B;AAC7B,gDAA8B;AAC9B,kDAAgC;AAChC,2CAAyB;AACzB,yCAAuB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Cube Dev, Inc.
|
|
3
|
+
* @license Apache-2.0
|
|
4
|
+
* @fileoverview Named pool wrapper around generic-pool with enhanced error messages.
|
|
5
|
+
*/
|
|
6
|
+
import { Factory, Options } from 'generic-pool';
|
|
7
|
+
export { Factory, Options as PoolOptions } from 'generic-pool';
|
|
8
|
+
export declare class PoolTimeoutError extends Error {
|
|
9
|
+
readonly poolName: string;
|
|
10
|
+
constructor(poolName: string);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Uses composition instead of inheritance because generic-pool doesn't export
|
|
14
|
+
* a Pool class, the Pool type is an interface, not an extendable class.
|
|
15
|
+
*/
|
|
16
|
+
export declare class Pool<T> {
|
|
17
|
+
private readonly pool;
|
|
18
|
+
private readonly name;
|
|
19
|
+
constructor(name: string, factory: Factory<T>, options?: Options);
|
|
20
|
+
acquire(priority?: number): Promise<T>;
|
|
21
|
+
release(resource: T): Promise<void>;
|
|
22
|
+
destroy(resource: T): Promise<void>;
|
|
23
|
+
drain(): Promise<void>;
|
|
24
|
+
clear(): Promise<void>;
|
|
25
|
+
use<U>(cb: (resource: T) => U | Promise<U>): Promise<U>;
|
|
26
|
+
get size(): number;
|
|
27
|
+
get available(): number;
|
|
28
|
+
get borrowed(): number;
|
|
29
|
+
get pending(): number;
|
|
30
|
+
get max(): number;
|
|
31
|
+
get min(): number;
|
|
32
|
+
on(event: 'factoryCreateError' | 'factoryDestroyError', listener: (err: Error) => void): this;
|
|
33
|
+
get _factory(): Factory<T>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/pool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAoB,EAAuB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAElF,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAE/D,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAEd,QAAQ,EAAE,MAAM;CAKpC;AAED;;;GAGG;AACH,qBAAa,IAAI,CAAC,CAAC;IACjB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiB;IAEtC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;gBAEX,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO;IAK1D,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAYtC,OAAO,CAAC,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAInC,OAAO,CAAC,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAInC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAYpE,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,IAAW,GAAG,IAAI,MAAM,CAEvB;IAED,IAAW,GAAG,IAAI,MAAM,CAEvB;IAGM,EAAE,CAAC,KAAK,EAAE,oBAAoB,GAAG,qBAAqB,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI;IAMpG,IAAW,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,CAGhC;CACF"}
|
package/dist/src/pool.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @copyright Cube Dev, Inc.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
* @fileoverview Named pool wrapper around generic-pool with enhanced error messages.
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.Pool = exports.PoolTimeoutError = void 0;
|
|
12
|
+
const generic_pool_1 = __importDefault(require("generic-pool"));
|
|
13
|
+
class PoolTimeoutError extends Error {
|
|
14
|
+
poolName;
|
|
15
|
+
constructor(poolName) {
|
|
16
|
+
super(`ResourceRequest timed out (pool: ${poolName})`);
|
|
17
|
+
this.name = 'PoolTimeoutError';
|
|
18
|
+
this.poolName = poolName;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.PoolTimeoutError = PoolTimeoutError;
|
|
22
|
+
/**
|
|
23
|
+
* Uses composition instead of inheritance because generic-pool doesn't export
|
|
24
|
+
* a Pool class, the Pool type is an interface, not an extendable class.
|
|
25
|
+
*/
|
|
26
|
+
class Pool {
|
|
27
|
+
pool;
|
|
28
|
+
name;
|
|
29
|
+
constructor(name, factory, options) {
|
|
30
|
+
this.name = name;
|
|
31
|
+
this.pool = generic_pool_1.default.createPool(factory, options);
|
|
32
|
+
}
|
|
33
|
+
async acquire(priority) {
|
|
34
|
+
try {
|
|
35
|
+
return await this.pool.acquire(priority);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
39
|
+
throw new PoolTimeoutError(this.name);
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async release(resource) {
|
|
45
|
+
return this.pool.release(resource);
|
|
46
|
+
}
|
|
47
|
+
async destroy(resource) {
|
|
48
|
+
return this.pool.destroy(resource);
|
|
49
|
+
}
|
|
50
|
+
async drain() {
|
|
51
|
+
return this.pool.drain();
|
|
52
|
+
}
|
|
53
|
+
async clear() {
|
|
54
|
+
return this.pool.clear();
|
|
55
|
+
}
|
|
56
|
+
async use(cb) {
|
|
57
|
+
try {
|
|
58
|
+
return await this.pool.use(cb);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error instanceof Error && error.name === 'TimeoutError') {
|
|
62
|
+
throw new PoolTimeoutError(this.name);
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// State accessors
|
|
68
|
+
get size() {
|
|
69
|
+
return this.pool.size;
|
|
70
|
+
}
|
|
71
|
+
get available() {
|
|
72
|
+
return this.pool.available;
|
|
73
|
+
}
|
|
74
|
+
get borrowed() {
|
|
75
|
+
return this.pool.borrowed;
|
|
76
|
+
}
|
|
77
|
+
get pending() {
|
|
78
|
+
return this.pool.pending;
|
|
79
|
+
}
|
|
80
|
+
get max() {
|
|
81
|
+
return this.pool.max;
|
|
82
|
+
}
|
|
83
|
+
get min() {
|
|
84
|
+
return this.pool.min;
|
|
85
|
+
}
|
|
86
|
+
// Event handling
|
|
87
|
+
on(event, listener) {
|
|
88
|
+
this.pool.on(event, listener);
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
// For backward compatibility (drivers use pool._factory for testConnection)
|
|
92
|
+
get _factory() {
|
|
93
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
94
|
+
return this.pool._factory;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.Pool = Pool;
|
|
98
|
+
//# sourceMappingURL=pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/pool.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,gEAAkF;AAIlF,MAAa,gBAAiB,SAAQ,KAAK;IACzB,QAAQ,CAAS;IAEjC,YAAmB,QAAgB;QACjC,KAAK,CAAC,oCAAoC,QAAQ,GAAG,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AARD,4CAQC;AAED;;;GAGG;AACH,MAAa,IAAI;IACE,IAAI,CAAiB;IAErB,IAAI,CAAS;IAE9B,YAAmB,IAAY,EAAE,OAAmB,EAAE,OAAiB;QACrE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,sBAAW,CAAC,UAAU,CAAI,OAA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,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;IAC7B,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IACvB,CAAC;IAED,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IACvB,CAAC;IAED,iBAAiB;IACV,EAAE,CAAC,KAAmD,EAAE,QAA8B;QAC3F,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,4EAA4E;IAC5E,IAAW,QAAQ;QACjB,gDAAgD;QAChD,OAAQ,IAAI,CAAC,IAAY,CAAC,QAAQ,CAAC;IACrC,CAAC;CACF;AArFD,oBAqFC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cubejs-backend/shared",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.10",
|
|
4
4
|
"description": "Shared code for Cube.js backend packages",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"typings": "dist/src/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@cubejs-backend/linter": "1.6.
|
|
30
|
+
"@cubejs-backend/linter": "1.6.10",
|
|
31
31
|
"@types/bytes": "^3.1.5",
|
|
32
32
|
"@types/cli-progress": "^3.9.1",
|
|
33
33
|
"@types/decompress": "^4.2.7",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"decompress": "^4.2.1",
|
|
49
49
|
"env-var": "^6.3.0",
|
|
50
50
|
"fs-extra": "^9.1.0",
|
|
51
|
+
"generic-pool": "^3.9.0",
|
|
51
52
|
"lru-cache": "^11.1.0",
|
|
52
53
|
"moment-range": "^4.0.2",
|
|
53
54
|
"moment-timezone": "^0.5.47",
|
|
@@ -66,5 +67,5 @@
|
|
|
66
67
|
"resolutions": {
|
|
67
68
|
"colors": "1.4.0"
|
|
68
69
|
},
|
|
69
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "4b4bdf283aba33cd82cba9dcea0f8fe226f4559c"
|
|
70
71
|
}
|