dt-common-device 13.10.2 → 13.10.4
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.
|
@@ -54,7 +54,6 @@ let HybridHttpQueue = (() => {
|
|
|
54
54
|
// BullMQ queues and workers for persistent storage
|
|
55
55
|
this.queues = new Map();
|
|
56
56
|
this.workers = new Map();
|
|
57
|
-
this.jobResults = new Map();
|
|
58
57
|
this.rateLimitConfigs = rateLimit_utils_1.RateLimitUtils.initializeRateLimitConfigs();
|
|
59
58
|
}
|
|
60
59
|
async addToQueue(connectionId, provider, url, method, options) {
|
|
@@ -89,7 +88,7 @@ let HybridHttpQueue = (() => {
|
|
|
89
88
|
console.log(`[${new Date().toISOString()}] [HybridHttpQueue] Job added to queue - JobId: ${jobId}, QueueKey: ${queueKey}`);
|
|
90
89
|
// Initialize worker if not exists
|
|
91
90
|
console.log(`[${new Date().toISOString()}] [HybridHttpQueue] Initializing worker for queue: ${queueKey}`);
|
|
92
|
-
queueUtils_1.QueueUtils.getOrCreateWorker(queueKey, this.workers, this.processHttpRequest.bind(this)
|
|
91
|
+
queueUtils_1.QueueUtils.getOrCreateWorker(queueKey, this.workers, this.processHttpRequest.bind(this));
|
|
93
92
|
// Verify worker was created
|
|
94
93
|
if (this.workers.has(queueKey)) {
|
|
95
94
|
console.log(`[${new Date().toISOString()}] [HybridHttpQueue] Worker confirmed for queue: ${queueKey}`);
|
|
@@ -170,7 +169,6 @@ let HybridHttpQueue = (() => {
|
|
|
170
169
|
]);
|
|
171
170
|
this.workers.clear();
|
|
172
171
|
this.queues.clear();
|
|
173
|
-
this.jobResults.clear();
|
|
174
172
|
(0, config_1.getConfig)().LOGGER.info("HTTP queues shutdown complete");
|
|
175
173
|
}
|
|
176
174
|
};
|
|
@@ -4,7 +4,7 @@ export declare class QueueUtils {
|
|
|
4
4
|
static getQueueKey(microservice: string, connectionId: string, provider: string): string;
|
|
5
5
|
static getRequestQueueKey(connectionId: string, provider: string): string;
|
|
6
6
|
static getOrCreateQueue(queueKey: string, queues: Map<string, any>): any;
|
|
7
|
-
static getOrCreateWorker(queueKey: string, workers: Map<string, any>, processFunction: (job: any) => Promise<any
|
|
7
|
+
static getOrCreateWorker(queueKey: string, workers: Map<string, any>, processFunction: (job: any) => Promise<any>): void;
|
|
8
8
|
static waitForRateLimitExpiry(connectionId: string, provider: string, rateLimitConfigs: Map<string, IRateLimitConfig>): Promise<void>;
|
|
9
9
|
static executeHttpRequest(url: string, method: string, options: HttpCallOption, connectionId: string, provider: string): Promise<any>;
|
|
10
10
|
static addJobToQueue(queueKey: string, jobData: any, delay: number, queues: Map<string, any>): Promise<string>;
|
|
@@ -24,7 +24,7 @@ class QueueUtils {
|
|
|
24
24
|
}))
|
|
25
25
|
.get(queueKey));
|
|
26
26
|
}
|
|
27
|
-
static getOrCreateWorker(queueKey, workers, processFunction
|
|
27
|
+
static getOrCreateWorker(queueKey, workers, processFunction) {
|
|
28
28
|
if (workers.has(queueKey)) {
|
|
29
29
|
const existingWorker = workers.get(queueKey);
|
|
30
30
|
console.log(`[${new Date().toISOString()}] [getOrCreateWorker] Worker already exists for queue: ${queueKey}, checking if it's running...`);
|
|
@@ -95,24 +95,11 @@ class QueueUtils {
|
|
|
95
95
|
console.log(`[${new Date().toISOString()}] [Worker Event] Job completed - JobId: ${job.id}, QueueKey: ${queueKey}, ReturnValueType: ${typeof job.returnvalue}, HasReturnValue: ${job.returnvalue !== undefined}`);
|
|
96
96
|
(0, config_1.getConfig)().LOGGER.info(`HTTP request completed: ${job.id} [${queueKey}]`);
|
|
97
97
|
const result = job.returnvalue;
|
|
98
|
-
const jobResult = {
|
|
99
|
-
result,
|
|
100
|
-
resolved: true,
|
|
101
|
-
timestamp: Date.now(),
|
|
102
|
-
};
|
|
103
98
|
console.log(`[${new Date().toISOString()}] [Worker Event] Storing job result - JobId: ${job.id}, ResultType: ${typeof result}, Resolved: true`);
|
|
104
|
-
jobResults.set(job.id, jobResult);
|
|
105
|
-
console.log(`[${new Date().toISOString()}] [Worker Event] Job result stored in jobResults - JobId: ${job.id}, StoredResult: ${JSON.stringify(jobResult)}`);
|
|
106
99
|
});
|
|
107
100
|
worker.on("failed", (job, err) => {
|
|
108
101
|
console.log(`[${new Date().toISOString()}] [Worker Event] Job failed - JobId: ${job?.id}, QueueKey: ${queueKey}, Error: ${err.message}`);
|
|
109
102
|
(0, config_1.getConfig)().LOGGER.error(`HTTP request failed: ${job?.id} [${queueKey}], Error: ${err.message}`);
|
|
110
|
-
jobResults.set(job.id, {
|
|
111
|
-
error: err.message,
|
|
112
|
-
resolved: true,
|
|
113
|
-
timestamp: Date.now(),
|
|
114
|
-
});
|
|
115
|
-
console.log(`[${new Date().toISOString()}] [Worker Event] Job error stored in jobResults - JobId: ${job?.id}`);
|
|
116
103
|
});
|
|
117
104
|
worker.on("error", (err) => {
|
|
118
105
|
console.log(`[${new Date().toISOString()}] [Worker Event] Worker error - QueueKey: ${queueKey}, Error: ${err.message}, Stack: ${err.stack}`);
|
|
@@ -76,7 +76,7 @@ class RateLimitUtils {
|
|
|
76
76
|
maxTimeoutWindowMs: 120000,
|
|
77
77
|
});
|
|
78
78
|
configs.set(constants_1.CONNECTION_PROVIDERS.SMARTTHINGS, {
|
|
79
|
-
maxRequests:
|
|
79
|
+
maxRequests: 25,
|
|
80
80
|
windowMs: 60000, // 1 minute
|
|
81
81
|
provider: constants_1.CONNECTION_PROVIDERS.SMARTTHINGS,
|
|
82
82
|
maxTimeoutWindowMs: 120000,
|