@diia-inhouse/diia-queue 14.1.0 → 14.1.2
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/dist/providers/rabbitmq/index.js +2 -2
- package/dist/services/communicator.js +3 -3
- package/dist/services/eventBus.js +7 -7
- package/dist/services/eventCommunicator.js +3 -3
- package/dist/services/externalEventBus.js +4 -4
- package/dist/services/scheduledTask.js +9 -9
- package/dist/services/task.js +5 -5
- package/package.json +5 -5
|
@@ -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 _ 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, _.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);
|
|
@@ -135,14 +135,14 @@ var Communicator = class {
|
|
|
135
135
|
unifyServiceConfig(listeners, implicitExchangesOptions = []) {
|
|
136
136
|
const queuesMap = /* @__PURE__ */ new Map();
|
|
137
137
|
const exchangesMap = /* @__PURE__ */ new Map();
|
|
138
|
+
const { queuesOptions, exchangesOptions: explicitExchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
|
|
139
|
+
for (const exchangeOpts of [...explicitExchangesOptions, ...implicitExchangesOptions]) if (!exchangesMap.has(exchangeOpts.name)) exchangesMap.set(exchangeOpts.name, exchangeOpts);
|
|
138
140
|
for (const listener of listeners) {
|
|
139
141
|
const { queueOptions, exchangesOptions } = listener;
|
|
140
142
|
queuesMap.set(queueOptions.name, queueOptions);
|
|
141
|
-
for (const exchangeOptions of exchangesOptions) exchangesMap.set(exchangeOptions.name, exchangeOptions);
|
|
143
|
+
for (const exchangeOptions of exchangesOptions) if (!exchangesMap.has(exchangeOptions.name)) exchangesMap.set(exchangeOptions.name, exchangeOptions);
|
|
142
144
|
}
|
|
143
|
-
const { queuesOptions, exchangesOptions: explicitExchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
|
|
144
145
|
for (const queueOpts of queuesOptions) if (!queuesMap.has(queueOpts.name)) queuesMap.set(queueOpts.name, queueOpts);
|
|
145
|
-
for (const exchangeOpts of [...explicitExchangesOptions, ...implicitExchangesOptions]) if (!exchangesMap.has(exchangeOpts.name)) exchangesMap.set(exchangeOpts.name, exchangeOpts);
|
|
146
146
|
return {
|
|
147
147
|
queuesOptions: [...queuesMap.values()],
|
|
148
148
|
exchangesOptions: [...exchangesMap.values()]
|
|
@@ -25,15 +25,15 @@ var EventBus = class extends Communicator {
|
|
|
25
25
|
getProducerExchangesOptions() {
|
|
26
26
|
if (!this.queueName) return [];
|
|
27
27
|
const { rabbit: { declareOptions: { assertExchanges } = {} } } = this.queueProvider.getConfig();
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
for (const
|
|
31
|
-
name:
|
|
28
|
+
const exchangeNames = this.optionsBuilder.getExchangeNamesByQueueName(this.queueName);
|
|
29
|
+
const exchangesOptions = [];
|
|
30
|
+
for (const exchangeName of exchangeNames) exchangesOptions.push({
|
|
31
|
+
name: exchangeName,
|
|
32
32
|
declare: assertExchanges,
|
|
33
|
-
type: "topic"
|
|
33
|
+
type: "topic",
|
|
34
|
+
bindTo: []
|
|
34
35
|
});
|
|
35
|
-
|
|
36
|
-
return [...globalExchangesOptions, ...messageBrokerServiceConfigExchangesOptions];
|
|
36
|
+
return exchangesOptions;
|
|
37
37
|
}
|
|
38
38
|
getMulticastListeners() {
|
|
39
39
|
if (!this.queueName || this.eventListenerList.length === 0) return [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { collectEventBusListeners } from "../utils.js";
|
|
2
|
-
import
|
|
2
|
+
import _ 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 = _.keyBy(queuesOptions, "name");
|
|
37
|
+
const exchangesOptionsMap = _.keyBy(exchangesOptions, "name");
|
|
38
38
|
for (const eventListener of this.listenerList) {
|
|
39
39
|
const { queueNames = [] } = eventListener;
|
|
40
40
|
for (const queueName of queueNames) {
|
|
@@ -64,9 +64,8 @@ var ExternalEventBus = class ExternalEventBus extends Communicator {
|
|
|
64
64
|
return `${this.exchangePrefixName}${topic}`;
|
|
65
65
|
}
|
|
66
66
|
getProducerExchangesOptions() {
|
|
67
|
-
const [
|
|
68
|
-
|
|
69
|
-
return [...globalExchangesOptions, ...messageBrokerServiceConfigExchangesOptions];
|
|
67
|
+
const [exchangesOptions] = this.defineQueuesAndExchangesOptionsBasedOnGlobalConfig();
|
|
68
|
+
return exchangesOptions;
|
|
70
69
|
}
|
|
71
70
|
getMulticastListeners() {
|
|
72
71
|
const [exchangesOptions, queuesOptions] = this.defineQueuesAndExchangesOptionsBasedOnGlobalConfig();
|
|
@@ -123,7 +122,8 @@ var ExternalEventBus = class ExternalEventBus extends Communicator {
|
|
|
123
122
|
const exchangeOptions = {
|
|
124
123
|
name: exchangeName,
|
|
125
124
|
type: "topic",
|
|
126
|
-
declare: assertExchanges
|
|
125
|
+
declare: assertExchanges,
|
|
126
|
+
bindTo: []
|
|
127
127
|
};
|
|
128
128
|
exchangesMap.set(exchangeName, exchangeOptions);
|
|
129
129
|
}
|
|
@@ -38,21 +38,21 @@ var ScheduledTask = class extends Communicator {
|
|
|
38
38
|
return this.eventCommunicator.getMulticastListeners([queueOptions], exchangesOptions);
|
|
39
39
|
}
|
|
40
40
|
getProducerExchangesOptions() {
|
|
41
|
-
const
|
|
41
|
+
const exchangesOptions = [];
|
|
42
42
|
const { topics = {}, rabbit: { declareOptions: { assertExchanges } = {} } } = this.queueProvider.getConfig();
|
|
43
43
|
const createExchangeOptions = (exchangeName) => ({
|
|
44
44
|
name: exchangeName,
|
|
45
45
|
type: "topic",
|
|
46
|
-
declare: assertExchanges
|
|
46
|
+
declare: assertExchanges,
|
|
47
|
+
bindTo: []
|
|
47
48
|
});
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
for (const
|
|
51
|
-
const exchangeOptions = createExchangeOptions(
|
|
52
|
-
|
|
49
|
+
const exchangeNamesByQueueName = this.optionsBuilder.getExchangeNamesByQueueName(this.queueName);
|
|
50
|
+
const exchangeNamesSet = new Set([...Object.keys(topics), ...exchangeNamesByQueueName]);
|
|
51
|
+
for (const exchangeName of exchangeNamesSet) {
|
|
52
|
+
const exchangeOptions = createExchangeOptions(exchangeName);
|
|
53
|
+
exchangesOptions.push(exchangeOptions);
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
return [...globalExchangesOptions, ...messageBrokerServiceConfigExchangesOptions];
|
|
55
|
+
return exchangesOptions;
|
|
56
56
|
}
|
|
57
57
|
getRoutingKey(serviceName) {
|
|
58
58
|
return `${serviceName}.${this.eventRoutingPart}`;
|
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 _ from "lodash";
|
|
6
6
|
//#region src/services/task.ts
|
|
7
7
|
var Task = class extends Communicator {
|
|
8
8
|
serviceName;
|
|
@@ -18,8 +18,8 @@ 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 =
|
|
21
|
+
const queuesOptionsMap = _.keyBy(queuesOptions, "name");
|
|
22
|
+
const exchangesOptionsMap = _.keyBy(exchangesOptions, "name");
|
|
23
23
|
for (const task of this.taskList) {
|
|
24
24
|
const { name: taskName, isDelayed = false, queueNames = [] } = task;
|
|
25
25
|
if (queueNames.length === 0) {
|
|
@@ -69,8 +69,8 @@ var Task = class extends Communicator {
|
|
|
69
69
|
getUnicastListeners() {
|
|
70
70
|
const listeners = [];
|
|
71
71
|
const { queuesOptions, exchangesOptions } = this.queueProvider.getMessageBrokerServiceConfig();
|
|
72
|
-
const queuesOptionsMap =
|
|
73
|
-
const exchangesOptionsMap =
|
|
72
|
+
const queuesOptionsMap = _.keyBy(queuesOptions, "name");
|
|
73
|
+
const exchangesOptionsMap = _.keyBy(exchangesOptions, "name");
|
|
74
74
|
for (const task of this.taskList) {
|
|
75
75
|
const { queueNames = [], name: taskName, isDelayed = false } = task;
|
|
76
76
|
if (queueNames.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diia-inhouse/diia-queue",
|
|
3
|
-
"version": "14.1.
|
|
3
|
+
"version": "14.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Package provide queue functionality",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@diia-inhouse/configs": "7.0.1",
|
|
54
|
-
"@diia-inhouse/diia-logger": "4.4.
|
|
55
|
-
"@diia-inhouse/diia-metrics": "7.1.
|
|
56
|
-
"@diia-inhouse/env": "3.3.
|
|
54
|
+
"@diia-inhouse/diia-logger": "4.4.8",
|
|
55
|
+
"@diia-inhouse/diia-metrics": "7.1.46",
|
|
56
|
+
"@diia-inhouse/env": "3.3.29",
|
|
57
57
|
"@diia-inhouse/errors": "2.2.2",
|
|
58
58
|
"@diia-inhouse/oxc-config": "2.0.0",
|
|
59
59
|
"@diia-inhouse/test": "8.2.17",
|
|
60
60
|
"@diia-inhouse/types": "14.1.1",
|
|
61
|
-
"@diia-inhouse/utils": "6.0.
|
|
61
|
+
"@diia-inhouse/utils": "6.0.43",
|
|
62
62
|
"@diia-inhouse/validators": "2.2.33",
|
|
63
63
|
"@opentelemetry/api": "1.9.0",
|
|
64
64
|
"@types/lodash": "4.17.24",
|