@seidor-cloud-produtos/orbit-backend-lib 0.0.27 → 0.0.28
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.
|
@@ -3,13 +3,13 @@ import QueueConnection from '../../../application/queue/queue-connection';
|
|
|
3
3
|
import QueueController from '../../../application/queue/queue-controller';
|
|
4
4
|
import DomainEvent from '../../../domain/events/domain-event';
|
|
5
5
|
export default class AmqpQueue implements QueueConnection {
|
|
6
|
-
private controller;
|
|
7
6
|
private uri;
|
|
8
7
|
private static instance;
|
|
9
8
|
private vHost;
|
|
10
9
|
private connection;
|
|
11
10
|
private messagesInMemory;
|
|
12
|
-
|
|
11
|
+
private controller;
|
|
12
|
+
constructor();
|
|
13
13
|
connect(vHost: string): Promise<any>;
|
|
14
14
|
close(): Promise<void>;
|
|
15
15
|
on(queueName: string, callback: Handler): Promise<void>;
|
|
@@ -19,10 +19,8 @@ export default class AmqpQueue implements QueueConnection {
|
|
|
19
19
|
configs?: Record<string, any>,
|
|
20
20
|
): Promise<void>;
|
|
21
21
|
createConsumers(queueName: string, configs: CreateConsumers): Promise<void>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
controller: QueueController,
|
|
25
|
-
): Promise<AmqpQueue>;
|
|
22
|
+
setController(controller?: QueueController): this;
|
|
23
|
+
static getInstance(vHost: string): Promise<AmqpQueue>;
|
|
26
24
|
private registerEvents;
|
|
27
25
|
private publishMessagesOfMemory;
|
|
28
26
|
}
|
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3
3
|
const tslib_1 = require('tslib');
|
|
4
4
|
const amqplib_1 = tslib_1.__importDefault(require('amqplib'));
|
|
5
5
|
class AmqpQueue {
|
|
6
|
-
constructor(
|
|
7
|
-
this.controller = controller;
|
|
6
|
+
constructor() {
|
|
8
7
|
this.messagesInMemory = [];
|
|
9
8
|
this.uri = process.env.BROKER_AMQP;
|
|
10
9
|
}
|
|
@@ -105,11 +104,17 @@ class AmqpQueue {
|
|
|
105
104
|
);
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
|
-
|
|
107
|
+
setController(controller) {
|
|
108
|
+
if (controller) {
|
|
109
|
+
this.controller = controller;
|
|
110
|
+
}
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
static async getInstance(vHost) {
|
|
109
114
|
if (AmqpQueue.instance && AmqpQueue.instance.vHost === vHost) {
|
|
110
115
|
return AmqpQueue.instance;
|
|
111
116
|
}
|
|
112
|
-
const queue = new AmqpQueue(
|
|
117
|
+
const queue = new AmqpQueue();
|
|
113
118
|
AmqpQueue.instance = await queue.connect(vHost);
|
|
114
119
|
return AmqpQueue.instance;
|
|
115
120
|
}
|