@diia-inhouse/diia-queue 14.2.49 → 14.2.51
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.
|
@@ -8,7 +8,7 @@ import { AmqpAsserter } from "./amqpAsserter.js";
|
|
|
8
8
|
import { AmqpConnection } from "./amqpConnection.js";
|
|
9
9
|
import { AmqpListener } from "./amqpListener.js";
|
|
10
10
|
import { AmqpPublisher } from "./amqpPublisher.js";
|
|
11
|
-
import
|
|
11
|
+
import lodash from "lodash";
|
|
12
12
|
import { randomUUID } from "node:crypto";
|
|
13
13
|
import { EventEmitter } from "node:events";
|
|
14
14
|
//#region src/providers/rabbitmq/index.ts
|
|
@@ -112,7 +112,7 @@ var RabbitMQProvider = class extends EventEmitter {
|
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
async makeAMQPConnection(client) {
|
|
115
|
-
return new AmqpConnection(this.rabbitmqConfig.connection, this.logger, this.rabbitmqConfig.reconnectOptions,
|
|
115
|
+
return new AmqpConnection(this.rabbitmqConfig.connection, this.logger, this.rabbitmqConfig.reconnectOptions, lodash.merge({ clientProperties: { connectionClientType: client } }, this.rabbitmqConfig.socketOptions));
|
|
116
116
|
}
|
|
117
117
|
async makeAMQPListener(queuesOptions) {
|
|
118
118
|
return new AmqpListener(await this.getConnection("listener"), this.logger, this.rabbitMQMetricsService, queuesOptions, this.systemServiceName);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { collectEventBusListeners } from "../utils.js";
|
|
2
|
-
import
|
|
2
|
+
import lodash from "lodash";
|
|
3
3
|
//#region src/services/eventCommunicator.ts
|
|
4
4
|
var EventCommunicator = class {
|
|
5
5
|
logger;
|
|
@@ -33,8 +33,8 @@ var EventCommunicator = class {
|
|
|
33
33
|
getUnicastListeners() {
|
|
34
34
|
const listeners = [];
|
|
35
35
|
const { queuesOptions, exchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
|
|
36
|
-
const queuesOptionsMap =
|
|
37
|
-
const exchangesOptionsMap =
|
|
36
|
+
const queuesOptionsMap = lodash.keyBy(queuesOptions, "name");
|
|
37
|
+
const exchangesOptionsMap = lodash.keyBy(exchangesOptions, "name");
|
|
38
38
|
for (const eventListener of this.listenerList) {
|
|
39
39
|
const { queueNames = [] } = eventListener;
|
|
40
40
|
for (const queueName of queueNames) {
|
package/dist/services/task.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ declare class Task extends Communicator implements TaskQueue, OnInit {
|
|
|
21
21
|
protected getMulticastListeners(): MessageBrokerServiceListener[];
|
|
22
22
|
protected getUnicastListeners(): MessageBrokerServiceListener[];
|
|
23
23
|
protected getExchangeNameWithSuffix(taskName: string): string;
|
|
24
|
+
private defineTaskExchangesOptions;
|
|
24
25
|
private defineExchangesOptions;
|
|
25
26
|
private defineQueueOptionsBasedOnGlobalConfig;
|
|
26
27
|
private defineExchangesOptionsBasedOnGlobalConfig;
|
package/dist/services/task.js
CHANGED
|
@@ -2,7 +2,7 @@ import { QueueTypes } from "../interfaces/messageBrokerServiceConfig.js";
|
|
|
2
2
|
import "../interfaces/index.js";
|
|
3
3
|
import constants_default from "../constants.js";
|
|
4
4
|
import Communicator from "./communicator.js";
|
|
5
|
-
import
|
|
5
|
+
import lodash from "lodash";
|
|
6
6
|
//#region src/services/task.ts
|
|
7
7
|
var Task = class extends Communicator {
|
|
8
8
|
serviceName;
|
|
@@ -18,27 +18,9 @@ var Task = class extends Communicator {
|
|
|
18
18
|
}
|
|
19
19
|
async onInit() {
|
|
20
20
|
const { queuesOptions, exchangesOptions } = await this.init();
|
|
21
|
-
const queuesOptionsMap =
|
|
22
|
-
const exchangesOptionsMap =
|
|
23
|
-
for (const task of this.taskList)
|
|
24
|
-
const { name: taskName, isDelayed = false, queueNames = [] } = task;
|
|
25
|
-
if (queueNames.length === 0) {
|
|
26
|
-
const queueName = this.defineQueueNameByTaskName(taskName, isDelayed, queuesOptionsMap, exchangesOptionsMap);
|
|
27
|
-
queueNames.push(queueName);
|
|
28
|
-
}
|
|
29
|
-
const taskExchangesOptions = [];
|
|
30
|
-
for (const queueName of queueNames) {
|
|
31
|
-
const queueOptions = queuesOptionsMap[queueName];
|
|
32
|
-
if (!queueOptions) {
|
|
33
|
-
this.logger.error(`Not found queue options by name (${queueName}) for task service`);
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
const { bindTo } = queueOptions;
|
|
37
|
-
const options = this.defineExchangesOptions(queueName, isDelayed, bindTo, exchangesOptionsMap);
|
|
38
|
-
taskExchangesOptions.push(...options);
|
|
39
|
-
}
|
|
40
|
-
this.taskNameExchangesOptionsMap.set(taskName, taskExchangesOptions);
|
|
41
|
-
}
|
|
21
|
+
const queuesOptionsMap = lodash.keyBy(queuesOptions, "name");
|
|
22
|
+
const exchangesOptionsMap = lodash.keyBy(exchangesOptions, "name");
|
|
23
|
+
for (const task of this.taskList) this.taskNameExchangesOptionsMap.set(task.name, this.defineTaskExchangesOptions(task, queuesOptionsMap, exchangesOptionsMap));
|
|
42
24
|
}
|
|
43
25
|
async publish(taskName, payload, delay) {
|
|
44
26
|
const exchangesOptions = this.taskNameExchangesOptionsMap.get(taskName);
|
|
@@ -61,7 +43,10 @@ var Task = class extends Communicator {
|
|
|
61
43
|
}
|
|
62
44
|
}
|
|
63
45
|
getProducerExchangesOptions() {
|
|
64
|
-
|
|
46
|
+
const { queuesOptions, exchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
|
|
47
|
+
const queuesOptionsMap = lodash.keyBy(queuesOptions, "name");
|
|
48
|
+
const exchangesOptionsMap = lodash.keyBy(exchangesOptions, "name");
|
|
49
|
+
return this.taskList.flatMap((task) => this.defineTaskExchangesOptions(task, queuesOptionsMap, exchangesOptionsMap));
|
|
65
50
|
}
|
|
66
51
|
getMulticastListeners() {
|
|
67
52
|
return [];
|
|
@@ -69,8 +54,8 @@ var Task = class extends Communicator {
|
|
|
69
54
|
getUnicastListeners() {
|
|
70
55
|
const listeners = [];
|
|
71
56
|
const { queuesOptions, exchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
|
|
72
|
-
const queuesOptionsMap =
|
|
73
|
-
const exchangesOptionsMap =
|
|
57
|
+
const queuesOptionsMap = lodash.keyBy(queuesOptions, "name");
|
|
58
|
+
const exchangesOptionsMap = lodash.keyBy(exchangesOptions, "name");
|
|
74
59
|
for (const task of this.taskList) {
|
|
75
60
|
const { queueNames = [], name: taskName, isDelayed = false } = task;
|
|
76
61
|
if (queueNames.length === 0) {
|
|
@@ -97,6 +82,20 @@ var Task = class extends Communicator {
|
|
|
97
82
|
getExchangeNameWithSuffix(taskName) {
|
|
98
83
|
return this.getQueueName(taskName);
|
|
99
84
|
}
|
|
85
|
+
defineTaskExchangesOptions(task, queuesOptionsMap, exchangesOptionsMap) {
|
|
86
|
+
const { name: taskName, isDelayed = false, queueNames = [] } = task;
|
|
87
|
+
const taskQueueNames = queueNames.length > 0 ? queueNames : [this.defineQueueNameByTaskName(taskName, isDelayed, queuesOptionsMap, exchangesOptionsMap)];
|
|
88
|
+
const taskExchangesOptions = [];
|
|
89
|
+
for (const queueName of taskQueueNames) {
|
|
90
|
+
const queueOptions = queuesOptionsMap[queueName];
|
|
91
|
+
if (!queueOptions) {
|
|
92
|
+
this.logger.error(`Not found queue options by name (${queueName}) for task service`);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
taskExchangesOptions.push(...this.defineExchangesOptions(queueName, isDelayed, queueOptions.bindTo, exchangesOptionsMap));
|
|
96
|
+
}
|
|
97
|
+
return taskExchangesOptions;
|
|
98
|
+
}
|
|
100
99
|
defineExchangesOptions(queueName, isExchangeDelayed = false, bindTo = [], exchangesMap = {}) {
|
|
101
100
|
const exchangesOptions = [];
|
|
102
101
|
for (const bindOptions of bindTo) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diia-inhouse/diia-queue",
|
|
3
|
-
"version": "14.2.
|
|
3
|
+
"version": "14.2.51",
|
|
4
4
|
"description": "Package provide queue functionality",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"author": "diia-team",
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
"lodash": "4.18.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@diia-inhouse/configs": "7.2.
|
|
41
|
-
"@diia-inhouse/diia-logger": "4.7.
|
|
42
|
-
"@diia-inhouse/diia-metrics": "7.1.
|
|
43
|
-
"@diia-inhouse/env": "3.3.
|
|
44
|
-
"@diia-inhouse/errors": "2.3.
|
|
40
|
+
"@diia-inhouse/configs": "7.2.4",
|
|
41
|
+
"@diia-inhouse/diia-logger": "4.7.42",
|
|
42
|
+
"@diia-inhouse/diia-metrics": "7.1.168",
|
|
43
|
+
"@diia-inhouse/env": "3.3.107",
|
|
44
|
+
"@diia-inhouse/errors": "2.3.38",
|
|
45
45
|
"@diia-inhouse/oxc-config": "5.0.2",
|
|
46
|
-
"@diia-inhouse/test": "8.4.
|
|
46
|
+
"@diia-inhouse/test": "8.4.2",
|
|
47
47
|
"@diia-inhouse/types": "14.12.0",
|
|
48
|
-
"@diia-inhouse/utils": "6.2.
|
|
49
|
-
"@diia-inhouse/validators": "2.2.
|
|
48
|
+
"@diia-inhouse/utils": "6.2.10",
|
|
49
|
+
"@diia-inhouse/validators": "2.2.132",
|
|
50
50
|
"@opentelemetry/api": "1.9.0",
|
|
51
51
|
"@types/lodash": "4.17.24",
|
|
52
52
|
"@types/node": "25.6.2",
|