@imqueue/core 1.15.0 → 2.0.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/LICENSE +585 -13
- package/README.md +2 -1
- package/eslint.config.mjs +21 -0
- package/index.d.ts +17 -11
- package/index.js +18 -12
- package/package.json +19 -20
- package/src/ClusterManager.d.ts +34 -0
- package/src/ClusterManager.js +13 -0
- package/src/ClusteredRedisQueue.d.ts +61 -22
- package/src/ClusteredRedisQueue.js +157 -31
- package/src/IMQMode.d.ts +17 -11
- package/src/IMQMode.js +17 -11
- package/src/IMessageQueue.d.ts +86 -30
- package/src/RedisQueue.d.ts +44 -41
- package/src/RedisQueue.js +160 -115
- package/src/UDPClusterManager.d.ts +82 -0
- package/src/UDPClusterManager.js +154 -0
- package/src/copyEventEmitter.d.ts +28 -0
- package/src/copyEventEmitter.js +23 -0
- package/src/index.d.ts +20 -11
- package/src/index.js +21 -13
- package/src/profile.d.ts +17 -11
- package/src/profile.js +21 -15
- package/src/promisify.d.ts +18 -11
- package/src/promisify.js +21 -15
- package/src/redis.d.ts +25 -24
- package/src/redis.js +44 -22
- package/src/uuid.js +18 -13
- package/debug.d.ts +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ICluster, ClusterManager } from './ClusterManager';
|
|
2
|
+
export declare const DEFAULT_UDP_BROADCAST_CLUSTER_MANAGER_OPTIONS: {
|
|
3
|
+
broadcastPort: number;
|
|
4
|
+
broadcastAddress: string;
|
|
5
|
+
aliveTimeoutCorrection: number;
|
|
6
|
+
};
|
|
7
|
+
export interface UDPClusterManagerOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Represents the cluster operations that are responsible for managing
|
|
10
|
+
* clusters. This includes operations such as adding, removing, or checking
|
|
11
|
+
* if a cluster server exists.
|
|
12
|
+
*
|
|
13
|
+
* @type {ICluster}
|
|
14
|
+
*/
|
|
15
|
+
cluster?: ICluster;
|
|
16
|
+
/**
|
|
17
|
+
* Message queue broadcast port
|
|
18
|
+
*
|
|
19
|
+
* @default 63000
|
|
20
|
+
* @type {number}
|
|
21
|
+
*/
|
|
22
|
+
broadcastPort?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Message queue broadcast address
|
|
25
|
+
*
|
|
26
|
+
* @default limitedBroadcastAddress
|
|
27
|
+
* @type {number}
|
|
28
|
+
*/
|
|
29
|
+
broadcastAddress?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Message queue limited broadcast address
|
|
32
|
+
*
|
|
33
|
+
* @default 255.255.255.255
|
|
34
|
+
* @type {string}
|
|
35
|
+
*/
|
|
36
|
+
limitedBroadcastAddress?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Message queue alive timeout correction. Used to correct waiting time to
|
|
39
|
+
* check if the server is alive
|
|
40
|
+
*
|
|
41
|
+
* @default 1000
|
|
42
|
+
* @type {number}
|
|
43
|
+
*/
|
|
44
|
+
aliveTimeoutCorrection?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Skip messages that are broadcast by specified addresses or set to
|
|
47
|
+
* "localhost" if you want to skip messages from "127.0.0.1" or "::1"
|
|
48
|
+
*
|
|
49
|
+
* @type {"local" | string[]}
|
|
50
|
+
*/
|
|
51
|
+
excludeHosts?: 'localhost' | string[];
|
|
52
|
+
/**
|
|
53
|
+
* Allow messages that are broadcast only by specified addresses or set to
|
|
54
|
+
* "localhost" if you want to allow messages only from "127.0.0.1" or "::1"
|
|
55
|
+
*
|
|
56
|
+
* @type {"local" | string[]}
|
|
57
|
+
*/
|
|
58
|
+
includeHosts?: 'localhost' | string[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* UDP broadcast-based cluster management implementation
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ~~~typescript
|
|
65
|
+
* const queue = new ClusteredRedisQueue('ClusteredQueue', {
|
|
66
|
+
* clusterManagers: [new UDPBroadcastClusterManager()],
|
|
67
|
+
* });
|
|
68
|
+
* ~~~
|
|
69
|
+
*/
|
|
70
|
+
export declare class UDPClusterManager extends ClusterManager {
|
|
71
|
+
private static sockets;
|
|
72
|
+
private readonly options;
|
|
73
|
+
constructor(options?: UDPClusterManagerOptions);
|
|
74
|
+
private listenBroadcastedMessages;
|
|
75
|
+
private startListening;
|
|
76
|
+
private static verifyHosts;
|
|
77
|
+
private static processMessageOnCluster;
|
|
78
|
+
private static processBroadcastedMessage;
|
|
79
|
+
private static parseBroadcastedMessage;
|
|
80
|
+
private static serverAliveWait;
|
|
81
|
+
private static selectNetworkInterface;
|
|
82
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UDPClusterManager = exports.DEFAULT_UDP_BROADCAST_CLUSTER_MANAGER_OPTIONS = void 0;
|
|
4
|
+
const ClusterManager_1 = require("./ClusterManager");
|
|
5
|
+
const dgram_1 = require("dgram");
|
|
6
|
+
const os_1 = require("os");
|
|
7
|
+
var BroadcastedMessageType;
|
|
8
|
+
(function (BroadcastedMessageType) {
|
|
9
|
+
BroadcastedMessageType["Up"] = "up";
|
|
10
|
+
BroadcastedMessageType["Down"] = "down";
|
|
11
|
+
})(BroadcastedMessageType || (BroadcastedMessageType = {}));
|
|
12
|
+
exports.DEFAULT_UDP_BROADCAST_CLUSTER_MANAGER_OPTIONS = {
|
|
13
|
+
broadcastPort: 63000,
|
|
14
|
+
broadcastAddress: '255.255.255.255',
|
|
15
|
+
aliveTimeoutCorrection: 1000,
|
|
16
|
+
};
|
|
17
|
+
const LOCALHOST_ADDRESSES = [
|
|
18
|
+
'localhost',
|
|
19
|
+
'127.0.0.1',
|
|
20
|
+
'::1',
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* UDP broadcast-based cluster management implementation
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ~~~typescript
|
|
27
|
+
* const queue = new ClusteredRedisQueue('ClusteredQueue', {
|
|
28
|
+
* clusterManagers: [new UDPBroadcastClusterManager()],
|
|
29
|
+
* });
|
|
30
|
+
* ~~~
|
|
31
|
+
*/
|
|
32
|
+
class UDPClusterManager extends ClusterManager_1.ClusterManager {
|
|
33
|
+
constructor(options) {
|
|
34
|
+
super();
|
|
35
|
+
this.options = Object.assign(Object.assign({}, exports.DEFAULT_UDP_BROADCAST_CLUSTER_MANAGER_OPTIONS), options || {});
|
|
36
|
+
this.startListening(this.options);
|
|
37
|
+
}
|
|
38
|
+
listenBroadcastedMessages(listener, options) {
|
|
39
|
+
const address = UDPClusterManager.selectNetworkInterface(options);
|
|
40
|
+
const key = `${address}:${options.broadcastPort}`;
|
|
41
|
+
if (!UDPClusterManager.sockets[key]) {
|
|
42
|
+
const socket = (0, dgram_1.createSocket)({ type: 'udp4', reuseAddr: true });
|
|
43
|
+
socket.bind(options.broadcastPort, address);
|
|
44
|
+
UDPClusterManager.sockets[key] = socket;
|
|
45
|
+
}
|
|
46
|
+
UDPClusterManager.sockets[key].on('message', message => listener(UDPClusterManager.parseBroadcastedMessage(message)));
|
|
47
|
+
}
|
|
48
|
+
startListening(options = {}) {
|
|
49
|
+
this.listenBroadcastedMessages(UDPClusterManager.processBroadcastedMessage(this), options);
|
|
50
|
+
}
|
|
51
|
+
static verifyHosts(host, hosts) {
|
|
52
|
+
const normalizedHosts = hosts === 'localhost'
|
|
53
|
+
? LOCALHOST_ADDRESSES
|
|
54
|
+
: hosts;
|
|
55
|
+
return normalizedHosts.includes(host);
|
|
56
|
+
}
|
|
57
|
+
static processMessageOnCluster(cluster, message, aliveTimeoutCorrection) {
|
|
58
|
+
const server = cluster.find(message);
|
|
59
|
+
if (server && message.type === BroadcastedMessageType.Down) {
|
|
60
|
+
clearTimeout(server.timer);
|
|
61
|
+
return cluster.remove(message);
|
|
62
|
+
}
|
|
63
|
+
if (!server && message.type === BroadcastedMessageType.Up) {
|
|
64
|
+
cluster.add(message);
|
|
65
|
+
const added = cluster.find(message);
|
|
66
|
+
if (added) {
|
|
67
|
+
UDPClusterManager.serverAliveWait(cluster, added, aliveTimeoutCorrection);
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (server && message.type === BroadcastedMessageType.Up) {
|
|
72
|
+
return UDPClusterManager.serverAliveWait(cluster, server, aliveTimeoutCorrection, message);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
static processBroadcastedMessage(context) {
|
|
76
|
+
return message => {
|
|
77
|
+
if (context.options.excludeHosts
|
|
78
|
+
&& UDPClusterManager.verifyHosts(message.host, context.options.excludeHosts)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (context.options.includeHosts
|
|
82
|
+
&& !UDPClusterManager.verifyHosts(message.host, context.options.includeHosts)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
for (const cluster of context.clusters) {
|
|
86
|
+
UDPClusterManager.processMessageOnCluster(cluster, message, context.options.aliveTimeoutCorrection);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
static parseBroadcastedMessage(input) {
|
|
91
|
+
const [name, id, type, address = '', timeout = '0',] = input.toString().split('\t');
|
|
92
|
+
const [host, port] = address.split(':');
|
|
93
|
+
return {
|
|
94
|
+
id,
|
|
95
|
+
name,
|
|
96
|
+
type: type.toLowerCase(),
|
|
97
|
+
host,
|
|
98
|
+
port: parseInt(port),
|
|
99
|
+
timeout: parseFloat(timeout) * 1000,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
static serverAliveWait(cluster, server, aliveTimeoutCorrection, message) {
|
|
103
|
+
clearTimeout(server.timer);
|
|
104
|
+
server.timestamp = Date.now();
|
|
105
|
+
if (message) {
|
|
106
|
+
server.timeout = message.timeout;
|
|
107
|
+
}
|
|
108
|
+
const correction = aliveTimeoutCorrection || 0;
|
|
109
|
+
const timeout = (server.timeout || 0) + correction;
|
|
110
|
+
server.timer = setTimeout(() => {
|
|
111
|
+
const existing = cluster.find(server);
|
|
112
|
+
if (!existing) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const now = Date.now();
|
|
116
|
+
const delta = now - (existing.timestamp || now);
|
|
117
|
+
const currentTimeout = (existing.timeout || 0) + correction;
|
|
118
|
+
if (delta >= currentTimeout) {
|
|
119
|
+
clearTimeout(server.timer);
|
|
120
|
+
cluster.remove(server);
|
|
121
|
+
}
|
|
122
|
+
}, timeout);
|
|
123
|
+
}
|
|
124
|
+
static selectNetworkInterface(options) {
|
|
125
|
+
const interfaces = (0, os_1.networkInterfaces)();
|
|
126
|
+
const limitedBroadcastAddress = options.limitedBroadcastAddress;
|
|
127
|
+
const broadcastAddress = options.broadcastAddress
|
|
128
|
+
|| limitedBroadcastAddress;
|
|
129
|
+
const defaultAddress = '0.0.0.0';
|
|
130
|
+
if (!broadcastAddress) {
|
|
131
|
+
return defaultAddress;
|
|
132
|
+
}
|
|
133
|
+
const equalAddresses = broadcastAddress === limitedBroadcastAddress;
|
|
134
|
+
if (equalAddresses) {
|
|
135
|
+
return defaultAddress;
|
|
136
|
+
}
|
|
137
|
+
for (const key in interfaces) {
|
|
138
|
+
if (!interfaces[key]) {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
for (const net of interfaces[key]) {
|
|
142
|
+
const shouldBeSelected = net.family === 'IPv4'
|
|
143
|
+
&& net.address.startsWith(broadcastAddress.replace(/\.255/g, ''));
|
|
144
|
+
if (shouldBeSelected) {
|
|
145
|
+
return net.address;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return defaultAddress;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.UDPClusterManager = UDPClusterManager;
|
|
153
|
+
UDPClusterManager.sockets = {};
|
|
154
|
+
//# sourceMappingURL=UDPClusterManager.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copies identical EventEmitter to the target
|
|
3
|
+
*
|
|
4
|
+
* I'm Queue Software Project
|
|
5
|
+
* Copyright (C) 2025 imqueue.com <support@imqueue.com>
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*
|
|
20
|
+
* If you want to use this code in a closed source (commercial) project, you can
|
|
21
|
+
* purchase a proprietary commercial license. Please contact us at
|
|
22
|
+
* <support@imqueue.com> to get commercial licensing options.
|
|
23
|
+
*/
|
|
24
|
+
import { EventEmitter } from 'events';
|
|
25
|
+
export declare function copyEventEmitter(source: EventEmitter & {
|
|
26
|
+
_maxListeners?: number;
|
|
27
|
+
_events?: Record<string | symbol, any>;
|
|
28
|
+
}, target: EventEmitter): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyEventEmitter = copyEventEmitter;
|
|
4
|
+
const util = require("util");
|
|
5
|
+
function copyEventEmitter(source, target) {
|
|
6
|
+
if (typeof source._maxListeners !== 'undefined') {
|
|
7
|
+
target.setMaxListeners(source.getMaxListeners());
|
|
8
|
+
}
|
|
9
|
+
for (const event of source.eventNames()) {
|
|
10
|
+
const listeners = source.rawListeners(event);
|
|
11
|
+
for (const originalListener of listeners) {
|
|
12
|
+
if (util.inspect(originalListener).includes('onceWrapper')) {
|
|
13
|
+
const realListener = (originalListener === null || originalListener === void 0 ? void 0 : originalListener.listener)
|
|
14
|
+
|| originalListener;
|
|
15
|
+
target.once(event, realListener);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
target.on(event, originalListener);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=copyEventEmitter.js.map
|
package/src/index.d.ts
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
*
|
|
2
|
+
* I'm Queue Software Project
|
|
3
|
+
* Copyright (C) 2025 imqueue.com <support@imqueue.com>
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*
|
|
18
|
+
* If you want to use this code in a closed source (commercial) project, you can
|
|
19
|
+
* purchase a proprietary commercial license. Please contact us at
|
|
20
|
+
* <support@imqueue.com> to get commercial licensing options.
|
|
15
21
|
*/
|
|
16
22
|
/**
|
|
17
23
|
* Safely builds full options definition using default options and
|
|
18
24
|
* partial given options
|
|
19
25
|
*
|
|
26
|
+
* @template T
|
|
20
27
|
* @param {T} defaultOptions
|
|
21
28
|
* @param {Partial<T>} givenOptions
|
|
22
29
|
* @return {T}
|
|
@@ -30,3 +37,5 @@ export * from './redis';
|
|
|
30
37
|
export * from './IMessageQueue';
|
|
31
38
|
export * from './RedisQueue';
|
|
32
39
|
export * from './ClusteredRedisQueue';
|
|
40
|
+
export * from './UDPClusterManager';
|
|
41
|
+
export * from './copyEventEmitter';
|
package/src/index.js
CHANGED
|
@@ -14,27 +14,34 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.buildOptions =
|
|
17
|
+
exports.buildOptions = buildOptions;
|
|
18
18
|
/*!
|
|
19
|
-
*
|
|
19
|
+
* I'm Queue Software Project
|
|
20
|
+
* Copyright (C) 2025 imqueue.com <support@imqueue.com>
|
|
21
|
+
*
|
|
22
|
+
* This program is free software: you can redistribute it and/or modify
|
|
23
|
+
* it under the terms of the GNU General Public License as published by
|
|
24
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
25
|
+
* (at your option) any later version.
|
|
20
26
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
27
|
+
* This program is distributed in the hope that it will be useful,
|
|
28
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
29
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
30
|
+
* GNU General Public License for more details.
|
|
24
31
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
32
|
+
* You should have received a copy of the GNU General Public License
|
|
33
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
34
|
+
*
|
|
35
|
+
* If you want to use this code in a closed source (commercial) project, you can
|
|
36
|
+
* purchase a proprietary commercial license. Please contact us at
|
|
37
|
+
* <support@imqueue.com> to get commercial licensing options.
|
|
32
38
|
*/
|
|
33
39
|
// noinspection JSUnusedGlobalSymbols
|
|
34
40
|
/**
|
|
35
41
|
* Safely builds full options definition using default options and
|
|
36
42
|
* partial given options
|
|
37
43
|
*
|
|
44
|
+
* @template T
|
|
38
45
|
* @param {T} defaultOptions
|
|
39
46
|
* @param {Partial<T>} givenOptions
|
|
40
47
|
* @return {T}
|
|
@@ -43,7 +50,6 @@ exports.buildOptions = void 0;
|
|
|
43
50
|
function buildOptions(defaultOptions, givenOptions) {
|
|
44
51
|
return Object.assign({}, defaultOptions, givenOptions);
|
|
45
52
|
}
|
|
46
|
-
exports.buildOptions = buildOptions;
|
|
47
53
|
__exportStar(require("./IMQMode"), exports);
|
|
48
54
|
__exportStar(require("./profile"), exports);
|
|
49
55
|
__exportStar(require("./uuid"), exports);
|
|
@@ -52,4 +58,6 @@ __exportStar(require("./redis"), exports);
|
|
|
52
58
|
__exportStar(require("./IMessageQueue"), exports);
|
|
53
59
|
__exportStar(require("./RedisQueue"), exports);
|
|
54
60
|
__exportStar(require("./ClusteredRedisQueue"), exports);
|
|
61
|
+
__exportStar(require("./UDPClusterManager"), exports);
|
|
62
|
+
__exportStar(require("./copyEventEmitter"), exports);
|
|
55
63
|
//# sourceMappingURL=index.js.map
|
package/src/profile.d.ts
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Decorator: @profile
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* I'm Queue Software Project
|
|
5
|
+
* Copyright (C) 2025 imqueue.com <support@imqueue.com>
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*
|
|
20
|
+
* If you want to use this code in a closed source (commercial) project, you can
|
|
21
|
+
* purchase a proprietary commercial license. Please contact us at
|
|
22
|
+
* <support@imqueue.com> to get commercial licensing options.
|
|
17
23
|
*/
|
|
18
24
|
import 'reflect-metadata';
|
|
19
25
|
import { ILogger } from '.';
|
package/src/profile.js
CHANGED
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.IMQ_LOG_TIME_FORMAT = exports.IMQ_LOG_ARGS = exports.IMQ_LOG_TIME = exports.IMQ_LOG_LEVEL = exports.LogLevel = void 0;
|
|
4
|
+
exports.verifyLogLevel = verifyLogLevel;
|
|
5
|
+
exports.logDebugInfo = logDebugInfo;
|
|
6
|
+
exports.profile = profile;
|
|
4
7
|
/*!
|
|
5
8
|
* Decorator: @profile
|
|
6
9
|
*
|
|
7
|
-
*
|
|
10
|
+
* I'm Queue Software Project
|
|
11
|
+
* Copyright (C) 2025 imqueue.com <support@imqueue.com>
|
|
12
|
+
*
|
|
13
|
+
* This program is free software: you can redistribute it and/or modify
|
|
14
|
+
* it under the terms of the GNU General Public License as published by
|
|
15
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
16
|
+
* (at your option) any later version.
|
|
8
17
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
18
|
+
* This program is distributed in the hope that it will be useful,
|
|
19
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
+
* GNU General Public License for more details.
|
|
12
22
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
+
* You should have received a copy of the GNU General Public License
|
|
24
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
25
|
+
*
|
|
26
|
+
* If you want to use this code in a closed source (commercial) project, you can
|
|
27
|
+
* purchase a proprietary commercial license. Please contact us at
|
|
28
|
+
* <support@imqueue.com> to get commercial licensing options.
|
|
20
29
|
*/
|
|
21
30
|
require("reflect-metadata");
|
|
22
31
|
var LogLevel;
|
|
@@ -44,7 +53,6 @@ function verifyLogLevel(level) {
|
|
|
44
53
|
return LogLevel.INFO;
|
|
45
54
|
}
|
|
46
55
|
}
|
|
47
|
-
exports.verifyLogLevel = verifyLogLevel;
|
|
48
56
|
exports.IMQ_LOG_LEVEL = verifyLogLevel(process.env.IMQ_LOG_LEVEL);
|
|
49
57
|
const DEFAULT_OPTIONS = {
|
|
50
58
|
logLevel: exports.IMQ_LOG_LEVEL,
|
|
@@ -135,7 +143,6 @@ function logDebugInfo({ debugTime, debugArgs, className, args, methodName, start
|
|
|
135
143
|
}
|
|
136
144
|
}
|
|
137
145
|
}
|
|
138
|
-
exports.logDebugInfo = logDebugInfo;
|
|
139
146
|
/**
|
|
140
147
|
* Implements '@profile' decorator.
|
|
141
148
|
*
|
|
@@ -214,5 +221,4 @@ function profile(options) {
|
|
|
214
221
|
};
|
|
215
222
|
};
|
|
216
223
|
}
|
|
217
|
-
exports.profile = profile;
|
|
218
224
|
//# sourceMappingURL=profile.js.map
|
package/src/promisify.d.ts
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Makes callback handling function promise-like
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* I'm Queue Software Project
|
|
5
|
+
* Copyright (C) 2025 imqueue.com <support@imqueue.com>
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*
|
|
20
|
+
* If you want to use this code in a closed source (commercial) project, you can
|
|
21
|
+
* purchase a proprietary commercial license. Please contact us at
|
|
22
|
+
* <support@imqueue.com> to get commercial licensing options.
|
|
17
23
|
*/
|
|
18
24
|
/**
|
|
19
25
|
* Returns entire list of the given object properties including
|
|
@@ -29,5 +35,6 @@ export declare function propertiesOf(obj: any): string[];
|
|
|
29
35
|
* @param {any} obj - source object to modify
|
|
30
36
|
* @param {string[]} restrict - stick promise-like behavior to a given
|
|
31
37
|
* restricted list of methods
|
|
38
|
+
* @return {void}
|
|
32
39
|
*/
|
|
33
40
|
export declare function promisify(obj: any, restrict?: string[]): void;
|
package/src/promisify.js
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.propertiesOf = propertiesOf;
|
|
4
|
+
exports.promisify = promisify;
|
|
2
5
|
/*!
|
|
3
6
|
* Makes callback handling function promise-like
|
|
4
7
|
*
|
|
5
|
-
*
|
|
8
|
+
* I'm Queue Software Project
|
|
9
|
+
* Copyright (C) 2025 imqueue.com <support@imqueue.com>
|
|
10
|
+
*
|
|
11
|
+
* This program is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
6
15
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
10
20
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
23
|
+
*
|
|
24
|
+
* If you want to use this code in a closed source (commercial) project, you can
|
|
25
|
+
* purchase a proprietary commercial license. Please contact us at
|
|
26
|
+
* <support@imqueue.com> to get commercial licensing options.
|
|
18
27
|
*/
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.promisify = exports.propertiesOf = void 0;
|
|
21
28
|
/**
|
|
22
29
|
* Returns entire list of the given object properties including
|
|
23
30
|
* entire prototype chain
|
|
@@ -37,7 +44,6 @@ function propertiesOf(obj) {
|
|
|
37
44
|
} while (obj = Object.getPrototypeOf(obj));
|
|
38
45
|
return props;
|
|
39
46
|
}
|
|
40
|
-
exports.propertiesOf = propertiesOf;
|
|
41
47
|
// istanbul ignore next
|
|
42
48
|
/**
|
|
43
49
|
* Makes a callback function able to resolve or reject with given
|
|
@@ -80,6 +86,7 @@ function makePromised(method) {
|
|
|
80
86
|
* @param {any} obj - source object to modify
|
|
81
87
|
* @param {string[]} restrict - stick promise-like behavior to a given
|
|
82
88
|
* restricted list of methods
|
|
89
|
+
* @return {void}
|
|
83
90
|
*/
|
|
84
91
|
function promisify(obj, restrict) {
|
|
85
92
|
for (const prop of propertiesOf(obj)) {
|
|
@@ -96,5 +103,4 @@ function promisify(obj, restrict) {
|
|
|
96
103
|
obj[prop] = makePromised(obj[prop]);
|
|
97
104
|
}
|
|
98
105
|
}
|
|
99
|
-
exports.promisify = promisify;
|
|
100
106
|
//# sourceMappingURL=promisify.js.map
|