@imqueue/rpc 1.13.14 → 1.14.1
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/index.js +5 -1
- package/package.json +17 -18
- package/src/IMQCache.js +1 -1
- package/src/IMQDelay.js +4 -4
- package/src/IMQLock.d.ts +3 -3
- package/src/IMQLock.js +1 -1
- package/src/IMQRPCDescription.js +1 -1
- package/src/cache/ICache.d.ts +1 -1
- package/src/cache/index.js +5 -1
- package/src/decorators/index.js +5 -1
- package/src/decorators/lock.d.ts +6 -1
- package/src/decorators/lock.js +9 -2
- package/src/decorators/logged.d.ts +1 -1
- package/src/helpers/index.js +5 -1
- package/src/index.js +5 -1
package/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imqueue/rpc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.1",
|
|
4
4
|
"description": "RPC-like client-service implementation over messaging queue",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"redis",
|
|
@@ -38,33 +38,32 @@
|
|
|
38
38
|
"author": "imqueue.com <support@imqueue.com> (https://imqueue.com)",
|
|
39
39
|
"license": "ISC",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@imqueue/core": "^1.
|
|
42
|
-
"@types/
|
|
43
|
-
"
|
|
44
|
-
"acorn": "^8.5.0",
|
|
41
|
+
"@imqueue/core": "^1.12.0",
|
|
42
|
+
"@types/node": "^20.1.4",
|
|
43
|
+
"acorn": "^8.8.2",
|
|
45
44
|
"murmurhash-native": "^3.5.0",
|
|
46
45
|
"node-machine-id": "^1.1.12",
|
|
47
46
|
"reflect-metadata": "^0.1.13",
|
|
48
|
-
"typescript": "^
|
|
47
|
+
"typescript": "^5.0.4"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
|
-
"@types/chai": "^4.
|
|
52
|
-
"@types/mocha": "^
|
|
53
|
-
"@types/mock-require": "^2.0.
|
|
54
|
-
"@types/sinon": "^10.0.
|
|
55
|
-
"chai": "^4.3.
|
|
50
|
+
"@types/chai": "^4.3.5",
|
|
51
|
+
"@types/mocha": "^10.0.1",
|
|
52
|
+
"@types/mock-require": "^2.0.1",
|
|
53
|
+
"@types/sinon": "^10.0.15",
|
|
54
|
+
"chai": "^4.3.7",
|
|
56
55
|
"codeclimate-test-reporter": "^0.5.1",
|
|
57
56
|
"coveralls": "^3.1.1",
|
|
58
|
-
"minimist": "
|
|
59
|
-
"mocha": "^
|
|
57
|
+
"minimist": "^1.2.8",
|
|
58
|
+
"mocha": "^10.2.0",
|
|
60
59
|
"mocha-lcov-reporter": "^1.3.0",
|
|
61
60
|
"mock-require": "^3.0.3",
|
|
62
61
|
"nyc": "^15.1.0",
|
|
63
|
-
"open": "^
|
|
64
|
-
"sinon": "^
|
|
65
|
-
"source-map-support": "^0.5.
|
|
66
|
-
"ts-node": "^10.
|
|
67
|
-
"typedoc": "^0.
|
|
62
|
+
"open": "^9.1.0",
|
|
63
|
+
"sinon": "^15.0.4",
|
|
64
|
+
"source-map-support": "^0.5.21",
|
|
65
|
+
"ts-node": "^10.9.1",
|
|
66
|
+
"typedoc": "^0.24.7"
|
|
68
67
|
},
|
|
69
68
|
"main": "index.js",
|
|
70
69
|
"typescript": {
|
package/src/IMQCache.js
CHANGED
package/src/IMQDelay.js
CHANGED
|
@@ -19,10 +19,6 @@ exports.IMQDelay = void 0;
|
|
|
19
19
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
20
20
|
*/
|
|
21
21
|
class IMQDelay {
|
|
22
|
-
constructor(timer, unit = 'ms') {
|
|
23
|
-
this.timer = timer;
|
|
24
|
-
this.unit = unit;
|
|
25
|
-
}
|
|
26
22
|
get ms() {
|
|
27
23
|
switch (this.unit) {
|
|
28
24
|
case 'ms': return this.timer;
|
|
@@ -32,6 +28,10 @@ class IMQDelay {
|
|
|
32
28
|
case 'd': return this.timer * 86400000;
|
|
33
29
|
}
|
|
34
30
|
}
|
|
31
|
+
constructor(timer, unit = 'ms') {
|
|
32
|
+
this.timer = timer;
|
|
33
|
+
this.unit = unit;
|
|
34
|
+
}
|
|
35
35
|
}
|
|
36
36
|
exports.IMQDelay = IMQDelay;
|
|
37
37
|
//# sourceMappingURL=IMQDelay.js.map
|
package/src/IMQLock.d.ts
CHANGED
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
17
17
|
*/
|
|
18
18
|
import { ILogger } from '@imqueue/core';
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
19
|
+
export type AcquiredLock<T> = T | boolean;
|
|
20
|
+
export type IMQLockTask = [(...args: any[]) => any, (...args: any[]) => any];
|
|
21
|
+
export type IMQLockQueue = Array<IMQLockTask>;
|
|
22
22
|
export interface IMQLockMetadataItem {
|
|
23
23
|
className: string;
|
|
24
24
|
methodName: string | symbol;
|
package/src/IMQLock.js
CHANGED
|
@@ -147,7 +147,6 @@ class IMQLock {
|
|
|
147
147
|
return !!IMQLock.acquiredLocks[key];
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
exports.IMQLock = IMQLock;
|
|
151
150
|
IMQLock.acquiredLocks = {};
|
|
152
151
|
IMQLock.queues = {};
|
|
153
152
|
IMQLock.metadata = {};
|
|
@@ -163,4 +162,5 @@ IMQLock.deadlockTimeout = 10000;
|
|
|
163
162
|
* @type {ILogger}
|
|
164
163
|
*/
|
|
165
164
|
IMQLock.logger = console;
|
|
165
|
+
exports.IMQLock = IMQLock;
|
|
166
166
|
//# sourceMappingURL=IMQLock.js.map
|
package/src/IMQRPCDescription.js
CHANGED
|
@@ -20,7 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
20
20
|
exports.IMQRPCDescription = void 0;
|
|
21
21
|
class IMQRPCDescription {
|
|
22
22
|
}
|
|
23
|
-
exports.IMQRPCDescription = IMQRPCDescription;
|
|
24
23
|
IMQRPCDescription.serviceDescription = {};
|
|
25
24
|
IMQRPCDescription.typesDescription = {};
|
|
25
|
+
exports.IMQRPCDescription = IMQRPCDescription;
|
|
26
26
|
//# sourceMappingURL=IMQRPCDescription.js.map
|
package/src/cache/ICache.d.ts
CHANGED
package/src/cache/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/src/decorators/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/src/decorators/lock.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
export interface LockOptions {
|
|
2
|
+
disabled?: boolean;
|
|
3
|
+
skipArgs?: number[];
|
|
4
|
+
}
|
|
1
5
|
/**
|
|
2
6
|
* \@lock() decorator implementation
|
|
3
7
|
* Will make all simultaneous similar method calls locked to be resolved with
|
|
4
8
|
* the first obtained values. Similarity is identified by a bypassed method
|
|
5
9
|
* argument values.
|
|
6
10
|
*
|
|
11
|
+
* @param {boolean|LockOptions} enabledOrOptions - whether to enable locks or not
|
|
7
12
|
* @return {(
|
|
8
13
|
* target: any,
|
|
9
14
|
* methodName: (string),
|
|
10
15
|
* descriptor: TypedPropertyDescriptor<(...args: any[]) => any>
|
|
11
16
|
* ) => void}
|
|
12
17
|
*/
|
|
13
|
-
export declare function lock(
|
|
18
|
+
export declare function lock(enabledOrOptions?: boolean | LockOptions): (target: any, methodName: string | symbol, descriptor: TypedPropertyDescriptor<(...args: any[]) => any>) => void;
|
package/src/decorators/lock.js
CHANGED
|
@@ -25,14 +25,21 @@ const __1 = require("..");
|
|
|
25
25
|
* the first obtained values. Similarity is identified by a bypassed method
|
|
26
26
|
* argument values.
|
|
27
27
|
*
|
|
28
|
+
* @param {boolean|LockOptions} enabledOrOptions - whether to enable locks or not
|
|
28
29
|
* @return {(
|
|
29
30
|
* target: any,
|
|
30
31
|
* methodName: (string),
|
|
31
32
|
* descriptor: TypedPropertyDescriptor<(...args: any[]) => any>
|
|
32
33
|
* ) => void}
|
|
33
34
|
*/
|
|
34
|
-
function lock(
|
|
35
|
+
function lock(enabledOrOptions = true) {
|
|
35
36
|
return function (target, methodName, descriptor) {
|
|
37
|
+
const enabled = typeof enabledOrOptions === 'boolean'
|
|
38
|
+
? enabledOrOptions
|
|
39
|
+
: !enabledOrOptions.disabled;
|
|
40
|
+
const skipArgs = typeof enabledOrOptions === 'boolean'
|
|
41
|
+
? undefined
|
|
42
|
+
: enabledOrOptions.skipArgs;
|
|
36
43
|
const original = descriptor.value;
|
|
37
44
|
const className = typeof target === 'function'
|
|
38
45
|
? target.name // static
|
|
@@ -42,7 +49,7 @@ function lock(enabled = true) {
|
|
|
42
49
|
let lock;
|
|
43
50
|
let sig = '';
|
|
44
51
|
if (withLocks) {
|
|
45
|
-
sig = (0, __1.signature)(className, methodName, args);
|
|
52
|
+
sig = (0, __1.signature)(className, methodName, skipArgs ? args.filter((_, index) => !~skipArgs.indexOf(index)) : args);
|
|
46
53
|
lock = await __1.IMQLock.acquire(sig, undefined, {
|
|
47
54
|
className,
|
|
48
55
|
methodName,
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
17
17
|
*/
|
|
18
18
|
import { ILogger } from '@imqueue/core';
|
|
19
|
-
export
|
|
19
|
+
export type LoggedLogLevel = 'info' | 'log' | 'warn' | 'error';
|
|
20
20
|
export interface LoggedDecoratorOptions {
|
|
21
21
|
level?: LoggedLogLevel;
|
|
22
22
|
logger?: ILogger;
|
package/src/helpers/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|