@imqueue/rpc 3.2.0 → 3.2.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.d.ts +1 -1
- package/index.js +2 -18
- package/package.json +6 -2
- package/src/IMQCache.d.ts +1 -24
- package/src/IMQCache.js +37 -6
- package/src/IMQClient.d.ts +2 -2
- package/src/IMQClient.js +53 -86
- package/src/IMQDelay.js +1 -5
- package/src/IMQLock.d.ts +2 -2
- package/src/IMQLock.js +26 -6
- package/src/IMQMetadata.d.ts +1 -1
- package/src/IMQMetadata.js +25 -5
- package/src/IMQRPCDescription.js +1 -5
- package/src/IMQRPCError.d.ts +1 -1
- package/src/IMQRPCError.js +27 -7
- package/src/IMQRPCOptions.d.ts +5 -5
- package/src/IMQRPCOptions.js +10 -9
- package/src/IMQRPCRequest.d.ts +2 -2
- package/src/IMQRPCRequest.js +25 -2
- package/src/IMQRPCResponse.d.ts +2 -2
- package/src/IMQRPCResponse.js +25 -2
- package/src/IMQRequestContext.d.ts +2 -2
- package/src/IMQRequestContext.js +6 -8
- package/src/IMQService.d.ts +2 -2
- package/src/IMQService.js +36 -75
- package/src/cache/ICache.js +1 -2
- package/src/cache/RedisCache.d.ts +3 -23
- package/src/cache/RedisCache.js +14 -17
- package/src/cache/index.d.ts +2 -2
- package/src/cache/index.js +2 -18
- package/src/decorators/cache.d.ts +1 -1
- package/src/decorators/cache.js +14 -15
- package/src/decorators/classType.js +3 -6
- package/src/decorators/expose.js +6 -9
- package/src/decorators/index.d.ts +9 -9
- package/src/decorators/index.js +9 -25
- package/src/decorators/indexed.d.ts +1 -1
- package/src/decorators/indexed.js +6 -9
- package/src/decorators/lock.js +8 -11
- package/src/decorators/logged.d.ts +1 -1
- package/src/decorators/logged.js +25 -4
- package/src/decorators/metadata.js +1 -2
- package/src/decorators/property.js +7 -11
- package/src/decorators/remote.js +1 -4
- package/src/helpers/fs.js +7 -12
- package/src/helpers/index.d.ts +4 -4
- package/src/helpers/index.js +4 -20
- package/src/helpers/os-uuid.js +5 -8
- package/src/helpers/pid.d.ts +1 -1
- package/src/helpers/pid.js +12 -16
- package/src/helpers/signature.js +3 -6
- package/src/index.d.ts +14 -14
- package/src/index.js +14 -30
- package/tsconfig.json +5 -2
package/src/helpers/pid.d.ts
CHANGED
package/src/helpers/pid.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IMQ_PID_DIR = exports.IMQ_TMP_DIR = exports.SIGNALS = void 0;
|
|
4
|
-
exports.pid = pid;
|
|
5
|
-
exports.forgetPid = forgetPid;
|
|
6
1
|
/*!
|
|
7
2
|
* IMQ-RPC helpers: pid, forgetPid
|
|
8
3
|
*
|
|
@@ -26,20 +21,21 @@ exports.forgetPid = forgetPid;
|
|
|
26
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
27
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
28
23
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
import { resolve } from 'node:path';
|
|
25
|
+
import { existsSync, mkdirSync, writeFileSync, unlinkSync } from 'node:fs';
|
|
26
|
+
import {} from '@imqueue/core';
|
|
31
27
|
/**
|
|
32
28
|
* OS signals that should trigger pid file cleanup on process termination.
|
|
33
29
|
*/
|
|
34
|
-
|
|
30
|
+
export const SIGNALS = ['SIGTERM', 'SIGINT', 'SIGHUP', 'SIGQUIT'];
|
|
35
31
|
/**
|
|
36
32
|
* Base temporary directory used by imq-rpc.
|
|
37
33
|
*/
|
|
38
|
-
|
|
34
|
+
export const IMQ_TMP_DIR = process.env.TMPDIR || '/tmp';
|
|
39
35
|
/**
|
|
40
36
|
* Directory where imq-rpc stores its pid files.
|
|
41
37
|
*/
|
|
42
|
-
|
|
38
|
+
export const IMQ_PID_DIR = resolve(IMQ_TMP_DIR, '.imq-rpc');
|
|
43
39
|
/**
|
|
44
40
|
* Returns an increment-based process identifier for the given service name,
|
|
45
41
|
* creating the corresponding pid file under the given directory.
|
|
@@ -48,17 +44,17 @@ exports.IMQ_PID_DIR = (0, node_path_1.resolve)(exports.IMQ_TMP_DIR, '.imq-rpc');
|
|
|
48
44
|
* @param {string} [path] - directory to store the pid file in
|
|
49
45
|
* @returns {number} - the allocated increment-based identifier
|
|
50
46
|
*/
|
|
51
|
-
function pid(name, path =
|
|
47
|
+
export function pid(name, path = IMQ_PID_DIR) {
|
|
52
48
|
const pidFile = `${path}/${name}`;
|
|
53
49
|
const pidOpts = { encoding: 'utf8', flag: 'wx' };
|
|
54
|
-
if (!
|
|
55
|
-
|
|
50
|
+
if (!existsSync(path)) {
|
|
51
|
+
mkdirSync(path);
|
|
56
52
|
}
|
|
57
53
|
let id = 0;
|
|
58
54
|
let done = false;
|
|
59
55
|
while (!done) {
|
|
60
56
|
try {
|
|
61
|
-
|
|
57
|
+
writeFileSync(`${pidFile}-${id}.pid`, process.pid + '', pidOpts);
|
|
62
58
|
done = true;
|
|
63
59
|
}
|
|
64
60
|
catch (err) {
|
|
@@ -80,9 +76,9 @@ function pid(name, path = exports.IMQ_PID_DIR) {
|
|
|
80
76
|
* @param {ILogger} logger - logger instance
|
|
81
77
|
* @param {string} [path] - directory the pid file is stored in
|
|
82
78
|
*/
|
|
83
|
-
function forgetPid(name, id, logger, path =
|
|
79
|
+
export function forgetPid(name, id, logger, path = IMQ_PID_DIR) {
|
|
84
80
|
try {
|
|
85
|
-
|
|
81
|
+
unlinkSync(`${path}/${name}-${id}.pid`);
|
|
86
82
|
}
|
|
87
83
|
catch {
|
|
88
84
|
/* ignore */
|
package/src/helpers/signature.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.signature = signature;
|
|
4
1
|
/*!
|
|
5
2
|
* IMQ-RPC helpers: signature
|
|
6
3
|
*
|
|
@@ -24,7 +21,7 @@ exports.signature = signature;
|
|
|
24
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
25
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
26
23
|
*/
|
|
27
|
-
|
|
24
|
+
import { hash } from 'node:crypto';
|
|
28
25
|
/**
|
|
29
26
|
* Serializes a value into a deterministic, JSON-compatible string. It mirrors
|
|
30
27
|
* `JSON.stringify` semantics (including `toJSON` support and how `undefined`,
|
|
@@ -102,11 +99,11 @@ function serialize(value, ancestors) {
|
|
|
102
99
|
* @param {readonly unknown[]} args - arguments passed to the method
|
|
103
100
|
* @returns {string} - hexadecimal hash string
|
|
104
101
|
*/
|
|
105
|
-
function signature(className, methodName, args) {
|
|
102
|
+
export function signature(className, methodName, args) {
|
|
106
103
|
const data = serialize([className, methodName, args], []);
|
|
107
104
|
// one-shot native hash truncated to 64 bits (16 hex chars) — same key
|
|
108
105
|
// space as the previous farmhash fingerprint64, but ~3-4x faster per
|
|
109
106
|
// call on typical payloads (no WASM boundary, no bigint conversion)
|
|
110
|
-
return
|
|
107
|
+
return hash('sha256', data, 'hex').slice(0, 16);
|
|
111
108
|
}
|
|
112
109
|
//# sourceMappingURL=signature.js.map
|
package/src/index.d.ts
CHANGED
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
* purchase a proprietary commercial license. Please contact us at
|
|
20
20
|
* <support@imqueue.com> to get commercial licensing options.
|
|
21
21
|
*/
|
|
22
|
-
export * from './decorators';
|
|
23
|
-
export * from './cache';
|
|
24
|
-
export * from './IMQDelay';
|
|
25
|
-
export * from './IMQCache';
|
|
26
|
-
export * from './IMQRPCOptions';
|
|
27
|
-
export * from './IMQRPCDescription';
|
|
28
|
-
export * from './IMQRPCError';
|
|
29
|
-
export * from './IMQRPCRequest';
|
|
30
|
-
export * from './IMQRPCResponse';
|
|
31
|
-
export * from './IMQLock';
|
|
32
|
-
export * from './IMQService';
|
|
33
|
-
export * from './IMQClient';
|
|
34
|
-
export * from './IMQMetadata';
|
|
35
|
-
export * from './IMQRequestContext';
|
|
22
|
+
export * from './decorators/index.js';
|
|
23
|
+
export * from './cache/index.js';
|
|
24
|
+
export * from './IMQDelay.js';
|
|
25
|
+
export * from './IMQCache.js';
|
|
26
|
+
export * from './IMQRPCOptions.js';
|
|
27
|
+
export * from './IMQRPCDescription.js';
|
|
28
|
+
export * from './IMQRPCError.js';
|
|
29
|
+
export * from './IMQRPCRequest.js';
|
|
30
|
+
export * from './IMQRPCResponse.js';
|
|
31
|
+
export * from './IMQLock.js';
|
|
32
|
+
export * from './IMQService.js';
|
|
33
|
+
export * from './IMQClient.js';
|
|
34
|
+
export * from './IMQMetadata.js';
|
|
35
|
+
export * from './IMQRequestContext.js';
|
package/src/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
1
|
/*!
|
|
18
2
|
* I'm Queue Software Project
|
|
19
3
|
* Copyright (C) 2025 imqueue.com <support@imqueue.com>
|
|
@@ -35,18 +19,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
35
19
|
* purchase a proprietary commercial license. Please contact us at
|
|
36
20
|
* <support@imqueue.com> to get commercial licensing options.
|
|
37
21
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
22
|
+
export * from './decorators/index.js';
|
|
23
|
+
export * from './cache/index.js';
|
|
24
|
+
export * from './IMQDelay.js';
|
|
25
|
+
export * from './IMQCache.js';
|
|
26
|
+
export * from './IMQRPCOptions.js';
|
|
27
|
+
export * from './IMQRPCDescription.js';
|
|
28
|
+
export * from './IMQRPCError.js';
|
|
29
|
+
export * from './IMQRPCRequest.js';
|
|
30
|
+
export * from './IMQRPCResponse.js';
|
|
31
|
+
export * from './IMQLock.js';
|
|
32
|
+
export * from './IMQService.js';
|
|
33
|
+
export * from './IMQClient.js';
|
|
34
|
+
export * from './IMQMetadata.js';
|
|
35
|
+
export * from './IMQRequestContext.js';
|
|
52
36
|
//# sourceMappingURL=index.js.map
|
package/tsconfig.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"lib": ["
|
|
3
|
+
"target": "es2024",
|
|
4
|
+
"lib": ["es2024", "esnext.decorators"],
|
|
5
5
|
"moduleDetection": "force",
|
|
6
6
|
|
|
7
7
|
"module": "nodenext",
|
|
8
8
|
"moduleResolution": "nodenext",
|
|
9
9
|
"resolveJsonModule": true,
|
|
10
10
|
"esModuleInterop": true,
|
|
11
|
+
"verbatimModuleSyntax": true,
|
|
11
12
|
|
|
12
13
|
"types": ["node"],
|
|
13
14
|
|
|
@@ -19,6 +20,8 @@
|
|
|
19
20
|
"removeComments": false,
|
|
20
21
|
"newLine": "lf",
|
|
21
22
|
|
|
23
|
+
"skipLibCheck": true,
|
|
24
|
+
|
|
22
25
|
"strict": true,
|
|
23
26
|
"strictPropertyInitialization": false,
|
|
24
27
|
"noImplicitOverride": true,
|