@signageos/lib 23.9.1 → 23.9.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/README.md +2 -2
- package/dist/AMQP/CQRS/ICommand.d.ts +3 -36
- package/dist/AMQP/CQRS/ICommand.js +18 -0
- package/dist/AMQP/CQRS/ICommand.js.map +1 -1
- package/dist/AMQP/CQRS/ICommandError.d.ts +4 -4
- package/dist/AMQP/CQRS/commandQueue.d.ts +4 -59
- package/dist/AMQP/CQRS/commandQueue.js +16 -308
- package/dist/AMQP/CQRS/commandQueue.js.map +1 -1
- package/dist/AMQP/CQRS/commandResponseHelper.d.ts +4 -3
- package/dist/AMQP/CQRS/commandResponseHelper.js +18 -5
- package/dist/AMQP/CQRS/commandResponseHelper.js.map +1 -1
- package/dist/AMQP/CQRS/storedCommandQueue.d.ts +4 -27
- package/dist/AMQP/CQRS/storedCommandQueue.js +16 -296
- package/dist/AMQP/CQRS/storedCommandQueue.js.map +1 -1
- package/dist/AMQP/ChannelProvider.d.ts +5 -37
- package/dist/AMQP/ChannelProvider.js +9 -868
- package/dist/AMQP/ChannelProvider.js.map +1 -1
- package/dist/AMQP/DeviceActions/Bridge/deviceActionBridgeFactory.d.ts +4 -39
- package/dist/AMQP/DeviceActions/Bridge/deviceActionBridgeFactory.js +16 -287
- package/dist/AMQP/DeviceActions/Bridge/deviceActionBridgeFactory.js.map +1 -1
- package/dist/AMQP/DeviceActions/IDeviceAction.d.ts +4 -4
- package/dist/AMQP/DeviceActions/deviceActionsQueue.d.ts +2 -81
- package/dist/AMQP/DeviceActions/deviceActionsQueue.js +14 -531
- package/dist/AMQP/DeviceActions/deviceActionsQueue.js.map +1 -1
- package/dist/AMQP/EventSourcing/EventConsumer/AmqpEventConsumer.d.ts +2 -45
- package/dist/AMQP/EventSourcing/EventConsumer/AmqpEventConsumer.js +14 -211
- package/dist/AMQP/EventSourcing/EventConsumer/AmqpEventConsumer.js.map +1 -1
- package/dist/AMQP/EventSourcing/EventConsumer/IEventConsumer.d.ts +2 -11
- package/dist/AMQP/EventSourcing/EventConsumer/IEventConsumer.js +18 -0
- package/dist/AMQP/EventSourcing/EventConsumer/IEventConsumer.js.map +1 -1
- package/dist/AMQP/EventSourcing/EventConsumer/InMemoryEventConsumer.d.ts +2 -13
- package/dist/AMQP/EventSourcing/EventConsumer/InMemoryEventConsumer.js +14 -69
- package/dist/AMQP/EventSourcing/EventConsumer/InMemoryEventConsumer.js.map +1 -1
- package/dist/AMQP/EventSourcing/IEvent.d.ts +3 -70
- package/dist/AMQP/EventSourcing/IEvent.js +18 -0
- package/dist/AMQP/EventSourcing/IEvent.js.map +1 -1
- package/dist/AMQP/EventSourcing/Locked/deferredState.d.ts +2 -19
- package/dist/AMQP/EventSourcing/Locked/deferredState.js +15 -66
- package/dist/AMQP/EventSourcing/Locked/deferredState.js.map +1 -1
- package/dist/AMQP/EventSourcing/Locked/lockedEventConsumer.d.ts +2 -68
- package/dist/AMQP/EventSourcing/Locked/lockedEventConsumer.js +14 -429
- package/dist/AMQP/EventSourcing/Locked/lockedEventConsumer.js.map +1 -1
- package/dist/AMQP/EventSourcing/Locked/rejectedTimestamps.d.ts +2 -22
- package/dist/AMQP/EventSourcing/Locked/rejectedTimestamps.js +16 -59
- package/dist/AMQP/EventSourcing/Locked/rejectedTimestamps.js.map +1 -1
- package/dist/AMQP/EventSourcing/Locked/withLock.d.ts +2 -40
- package/dist/AMQP/EventSourcing/Locked/withLock.js +14 -134
- package/dist/AMQP/EventSourcing/Locked/withLock.js.map +1 -1
- package/dist/AMQP/EventSourcing/eventQueue.d.ts +2 -85
- package/dist/AMQP/EventSourcing/eventQueue.js +14 -132
- package/dist/AMQP/EventSourcing/eventQueue.js.map +1 -1
- package/dist/AMQP/EventSourcing/eventQueue.utils.d.ts +2 -71
- package/dist/AMQP/EventSourcing/eventQueue.utils.js +16 -152
- package/dist/AMQP/EventSourcing/eventQueue.utils.js.map +1 -1
- package/dist/AMQP/EventSourcing/eventQueueDetached.d.ts +2 -47
- package/dist/AMQP/EventSourcing/eventQueueDetached.js +14 -421
- package/dist/AMQP/EventSourcing/eventQueueDetached.js.map +1 -1
- package/dist/AMQP/EventSourcing/eventQueueDomain.d.ts +2 -53
- package/dist/AMQP/EventSourcing/eventQueueDomain.js +14 -611
- package/dist/AMQP/EventSourcing/eventQueueDomain.js.map +1 -1
- package/dist/AMQP/EventSourcing/eventQueuePublish.d.ts +2 -17
- package/dist/AMQP/EventSourcing/eventQueuePublish.js +14 -202
- package/dist/AMQP/EventSourcing/eventQueuePublish.js.map +1 -1
- package/dist/AMQP/EventSourcing/synchronization.d.ts +2 -37
- package/dist/AMQP/EventSourcing/synchronization.js +18 -9
- package/dist/AMQP/EventSourcing/synchronization.js.map +1 -1
- package/dist/AMQP/Exchange.d.ts +4 -1
- package/dist/AMQP/Exchange.js +18 -0
- package/dist/AMQP/Exchange.js.map +1 -1
- package/dist/AMQP/IAsyncGotMessage.d.ts +2 -13
- package/dist/AMQP/IAsyncGotMessage.js +18 -0
- package/dist/AMQP/IAsyncGotMessage.js.map +1 -1
- package/dist/AMQP/IChannel.d.ts +5 -43
- package/dist/AMQP/IChannel.js +18 -0
- package/dist/AMQP/IChannel.js.map +1 -1
- package/dist/AMQP/IConsumeOptions.d.ts +5 -106
- package/dist/AMQP/IConsumeOptions.js +18 -0
- package/dist/AMQP/IConsumeOptions.js.map +1 -1
- package/dist/AMQP/IMessageOptions.d.ts +5 -6
- package/dist/AMQP/IMessageOptions.js +18 -0
- package/dist/AMQP/IMessageOptions.js.map +1 -1
- package/dist/AMQP/INackOptions.d.ts +5 -4
- package/dist/AMQP/INackOptions.js +18 -0
- package/dist/AMQP/INackOptions.js.map +1 -1
- package/dist/AMQP/IQueueOptions.d.ts +5 -8
- package/dist/AMQP/IQueueOptions.js +18 -0
- package/dist/AMQP/IQueueOptions.js.map +1 -1
- package/dist/AMQP/Logging/IDeviceLog.d.ts +4 -15
- package/dist/AMQP/Logging/IDeviceLog.js +18 -7
- package/dist/AMQP/Logging/IDeviceLog.js.map +1 -1
- package/dist/AMQP/Logging/logDeviceQueue.d.ts +4 -12
- package/dist/AMQP/Logging/logDeviceQueue.js +16 -102
- package/dist/AMQP/Logging/logDeviceQueue.js.map +1 -1
- package/dist/AMQP/QueueFetcher.d.ts +3 -11
- package/dist/AMQP/QueueFetcher.js +17 -156
- package/dist/AMQP/QueueFetcher.js.map +1 -1
- package/dist/AMQP/QueuePublisher.d.ts +5 -7
- package/dist/AMQP/QueuePublisher.js +19 -127
- package/dist/AMQP/QueuePublisher.js.map +1 -1
- package/dist/AMQP/QueueRepeatableSubscription.d.ts +5 -14
- package/dist/AMQP/QueueRepeatableSubscription.js +19 -154
- package/dist/AMQP/QueueRepeatableSubscription.js.map +1 -1
- package/dist/AMQP/QueueSubscriber.d.ts +5 -27
- package/dist/AMQP/QueueSubscriber.js +9 -303
- package/dist/AMQP/QueueSubscriber.js.map +1 -1
- package/dist/AMQP/ResponseProvider.d.ts +4 -20
- package/dist/AMQP/ResponseProvider.js +16 -188
- package/dist/AMQP/ResponseProvider.js.map +1 -1
- package/dist/AMQP/Static/filesQueue.d.ts +4 -12
- package/dist/AMQP/Static/filesQueue.js +6 -205
- package/dist/AMQP/Static/filesQueue.js.map +1 -1
- package/dist/AMQP/amqpConnectionFactory.d.ts +2 -25
- package/dist/AMQP/amqpConnectionFactory.js +4 -219
- package/dist/AMQP/amqpConnectionFactory.js.map +1 -1
- package/dist/AMQP/amqpErrors.d.ts +4 -5
- package/dist/AMQP/amqpErrors.js +18 -27
- package/dist/AMQP/amqpErrors.js.map +1 -1
- package/dist/AMQP/errors.d.ts +4 -3
- package/dist/AMQP/errors.js +18 -27
- package/dist/AMQP/errors.js.map +1 -1
- package/dist/AMQP/fetchNextMessage.d.ts +3 -12
- package/dist/AMQP/fetchNextMessage.js +20 -111
- package/dist/AMQP/fetchNextMessage.js.map +1 -1
- package/dist/AMQP/queueConfigurator.d.ts +2 -3
- package/dist/AMQP/queueConfigurator.js +14 -71
- package/dist/AMQP/queueConfigurator.js.map +1 -1
- package/dist/DateTime/waitUntil.d.ts +4 -15
- package/dist/DateTime/waitUntil.js +17 -139
- package/dist/DateTime/waitUntil.js.map +1 -1
- package/dist/Events/AsyncEventEmitter.d.ts +2 -29
- package/dist/Events/AsyncEventEmitter.js +14 -118
- package/dist/Events/AsyncEventEmitter.js.map +1 -1
- package/dist/Events/eventsHelpers.d.ts +4 -3
- package/dist/Events/eventsHelpers.js +18 -21
- package/dist/Events/eventsHelpers.js.map +1 -1
- package/dist/Hash/checksum.d.ts +2 -3
- package/dist/Hash/checksum.js +16 -15
- package/dist/Hash/checksum.js.map +1 -1
- package/dist/Hash/checksumFile.d.ts +2 -2
- package/dist/Hash/checksumFile.js +4 -65
- package/dist/Hash/checksumFile.js.map +1 -1
- package/dist/Hash/generator.d.ts +4 -2
- package/dist/Hash/generator.js +18 -12
- package/dist/Hash/generator.js.map +1 -1
- package/dist/HttpStatus/checks/amqpStatusCheck.d.ts +1 -1
- package/dist/HttpStatus/statuses/amqpStatus.d.ts +1 -1
- package/dist/Metrics/MetricsClient.d.ts +2 -44
- package/dist/Metrics/MetricsClient.js +6 -86
- package/dist/Metrics/MetricsClient.js.map +1 -1
- package/dist/Metrics/metrics.d.ts +2 -82
- package/dist/Metrics/metrics.js +4 -238
- package/dist/Metrics/metrics.js.map +1 -1
- package/dist/Metrics/processSocketsMetrics.d.ts +4 -10
- package/dist/Metrics/processSocketsMetrics.js +17 -88
- package/dist/Metrics/processSocketsMetrics.js.map +1 -1
- package/dist/Service/dbConnections.d.ts +1 -1
- package/dist/Service/metrics/connections.js +7 -7
- package/dist/Service/metrics/connections.js.map +1 -1
- package/dist/ThirdParty/connection.d.ts +0 -11
- package/package.json +5 -9
- package/dist/AMQP/IAMQPPool.d.ts +0 -5
- package/dist/AMQP/IAMQPPool.js +0 -3
- package/dist/AMQP/IAMQPPool.js.map +0 -1
- package/dist/Events/genericGracefulExit.d.ts +0 -11
- package/dist/Events/genericGracefulExit.js +0 -90
- package/dist/Events/genericGracefulExit.js.map +0 -1
- package/dist/GenericPool/options.d.ts +0 -63
- package/dist/GenericPool/options.js +0 -3
- package/dist/GenericPool/options.js.map +0 -1
- package/dist/Metrics/deviceConsumerMetrics.d.ts +0 -6
- package/dist/Metrics/deviceConsumerMetrics.js +0 -59
- package/dist/Metrics/deviceConsumerMetrics.js.map +0 -1
- package/dist/Metrics/eventConsumerMetrics.d.ts +0 -19
- package/dist/Metrics/eventConsumerMetrics.js +0 -52
- package/dist/Metrics/eventConsumerMetrics.js.map +0 -1
- package/dist/Metrics/eventQueueMetrics.d.ts +0 -7
- package/dist/Metrics/eventQueueMetrics.js +0 -19
- package/dist/Metrics/eventQueueMetrics.js.map +0 -1
- package/dist/Pool/IBasePool.d.ts +0 -6
- package/dist/Pool/IBasePool.js +0 -3
- package/dist/Pool/IBasePool.js.map +0 -1
- package/dist/System/signalSender.d.ts +0 -1
- package/dist/System/signalSender.js +0 -7
- package/dist/System/signalSender.js.map +0 -1
|
@@ -1,218 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
21
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
22
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
23
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
24
|
-
function step(op) {
|
|
25
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
26
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
27
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
28
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
29
|
-
switch (op[0]) {
|
|
30
|
-
case 0: case 1: t = op; break;
|
|
31
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
32
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
33
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
34
|
-
default:
|
|
35
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
36
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
37
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
38
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
39
|
-
if (t[2]) _.ops.pop();
|
|
40
|
-
_.trys.pop(); continue;
|
|
41
|
-
}
|
|
42
|
-
op = body.call(thisArg, _);
|
|
43
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
44
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
45
7
|
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
46
15
|
};
|
|
47
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.AmqpEventConsumer = void 0;
|
|
49
|
-
var lockedDecorator_1 = require("../../../Lock/lockedDecorator");
|
|
50
|
-
var logging_1 = require("../../../Logging/logging");
|
|
51
|
-
var eventQueueDomain_1 = require("../eventQueueDomain");
|
|
52
|
-
var eventConsumerMetrics_1 = require("../../../Metrics/eventConsumerMetrics");
|
|
53
|
-
var consumerLogger = logging_1.logger.createNamespace('EventConsumer');
|
|
54
|
-
var DEFAULT_DOMAIN = 'default';
|
|
55
|
-
var LOCK_NAMESPACE = 'AmqpEventConsumer';
|
|
56
17
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* This implementation uses AMQP queues to consume events.
|
|
60
|
-
*
|
|
61
|
-
* It abstracts all the implementation details of setting up consumption of events
|
|
62
|
-
* and provides a simple interface so that the consumer can focus on just handling the events.
|
|
63
|
-
*
|
|
64
|
-
* All events are consumed from a single queue in a sequential order.
|
|
65
|
-
* The name of the queue will be constructed from the consumer name and the domain as "<consumerName>_<domain>".
|
|
18
|
+
* @deprecated Use `@signageos/amqp` instead.
|
|
66
19
|
*/
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @param amqpConnection The AMQP connection to use
|
|
70
|
-
* @param consumerName The name of the consumer. This is used to identify the consumer in the AMQP queue
|
|
71
|
-
* @param domain The domain to consume events from. Defaults to 'default'
|
|
72
|
-
* @param options Additional options for the consumer
|
|
73
|
-
*/
|
|
74
|
-
function AmqpEventConsumer(_a) {
|
|
75
|
-
var amqpConnection = _a.amqpConnection, consumerName = _a.consumerName, domain = _a.domain, options = _a.options;
|
|
76
|
-
this.consumerCallbacks = {};
|
|
77
|
-
this.stopCallback = null;
|
|
78
|
-
this.started = false;
|
|
79
|
-
this.amqpConnection = amqpConnection;
|
|
80
|
-
this.consumerName = consumerName;
|
|
81
|
-
this.domain = domain || DEFAULT_DOMAIN;
|
|
82
|
-
this.options = options;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Add a consumer for a specific event type
|
|
86
|
-
*
|
|
87
|
-
* Has to be called before calling listen(), otherwise it will throw an error.
|
|
88
|
-
*/
|
|
89
|
-
AmqpEventConsumer.prototype.addEventConsumer = function (eventType, callback, option) {
|
|
90
|
-
if (this.consumerCallbacks[eventType]) {
|
|
91
|
-
throw new Error("Consumer for event type ".concat(eventType, " already registered"));
|
|
92
|
-
}
|
|
93
|
-
if (this.started) {
|
|
94
|
-
throw new Error('Cannot add event consumer after consumer has started');
|
|
95
|
-
}
|
|
96
|
-
this.consumerCallbacks[eventType] = {
|
|
97
|
-
callback: callback,
|
|
98
|
-
schema: option === null || option === void 0 ? void 0 : option.schema,
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
AmqpEventConsumer.prototype.listen = function () {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
-
return __generator(this, function (_a) {
|
|
104
|
-
switch (_a.label) {
|
|
105
|
-
case 0:
|
|
106
|
-
if (this.started) {
|
|
107
|
-
throw new Error('Event consumer already started');
|
|
108
|
-
}
|
|
109
|
-
return [4 /*yield*/, this.bindEvents()];
|
|
110
|
-
case 1:
|
|
111
|
-
_a.sent();
|
|
112
|
-
this.started = true;
|
|
113
|
-
return [2 /*return*/];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
AmqpEventConsumer.prototype.close = function () {
|
|
119
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
-
var closeChannel;
|
|
121
|
-
return __generator(this, function (_a) {
|
|
122
|
-
switch (_a.label) {
|
|
123
|
-
case 0:
|
|
124
|
-
if (!this.stopCallback) return [3 /*break*/, 3];
|
|
125
|
-
return [4 /*yield*/, this.stopCallback()];
|
|
126
|
-
case 1:
|
|
127
|
-
closeChannel = _a.sent();
|
|
128
|
-
return [4 /*yield*/, closeChannel()];
|
|
129
|
-
case 2:
|
|
130
|
-
_a.sent();
|
|
131
|
-
this.stopCallback = null;
|
|
132
|
-
_a.label = 3;
|
|
133
|
-
case 3:
|
|
134
|
-
this.started = false;
|
|
135
|
-
return [2 /*return*/];
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
AmqpEventConsumer.prototype.bindEvents = function () {
|
|
141
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
142
|
-
var eventTypes, _a;
|
|
143
|
-
return __generator(this, function (_b) {
|
|
144
|
-
switch (_b.label) {
|
|
145
|
-
case 0:
|
|
146
|
-
eventTypes = Object.keys(this.consumerCallbacks);
|
|
147
|
-
_a = this;
|
|
148
|
-
return [4 /*yield*/, (0, eventQueueDomain_1.bindDomain)(this.amqpConnection, eventTypes, this.domain, this.consumerName, this.consumeEvent.bind(this), this.options)];
|
|
149
|
-
case 1:
|
|
150
|
-
_a.stopCallback = _b.sent();
|
|
151
|
-
return [2 /*return*/];
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
AmqpEventConsumer.prototype.shouldConsumeEvent = function (options) {
|
|
157
|
-
if (options.schema) {
|
|
158
|
-
return options.schema.safeParse(options.event).success;
|
|
159
|
-
}
|
|
160
|
-
return true;
|
|
161
|
-
};
|
|
162
|
-
AmqpEventConsumer.prototype.consumeEvent = function (event) {
|
|
163
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
164
|
-
var start, _a, callback, schema, e_1;
|
|
165
|
-
return __generator(this, function (_b) {
|
|
166
|
-
switch (_b.label) {
|
|
167
|
-
case 0:
|
|
168
|
-
start = new Date().getTime();
|
|
169
|
-
eventConsumerMetrics_1.metrics.emit('events_total', { eventType: event.type });
|
|
170
|
-
eventConsumerMetrics_1.metrics.emit('event_duration_seconds_total', { eventType: event.type, phase: 'eventStart' }, start - event.receivedAt.getTime());
|
|
171
|
-
eventConsumerMetrics_1.metrics.emit('event_duration_seconds_total', { eventType: event.type, phase: 'commandStart' }, event.receivedAt.getTime() - event.dispatchedAt.getTime());
|
|
172
|
-
_a = this.consumerCallbacks[event.type] || {}, callback = _a.callback, schema = _a.schema;
|
|
173
|
-
if (!callback) {
|
|
174
|
-
eventConsumerMetrics_1.metrics.emit('event_error_total', { eventType: event.type });
|
|
175
|
-
throw new Error("Event ".concat(event.type, " received but no consumer registered"));
|
|
176
|
-
}
|
|
177
|
-
if (!this.shouldConsumeEvent({ schema: schema, event: event })) return [3 /*break*/, 6];
|
|
178
|
-
_b.label = 1;
|
|
179
|
-
case 1:
|
|
180
|
-
_b.trys.push([1, 3, 4, 5]);
|
|
181
|
-
return [4 /*yield*/, callback(event)];
|
|
182
|
-
case 2:
|
|
183
|
-
_b.sent();
|
|
184
|
-
return [3 /*break*/, 5];
|
|
185
|
-
case 3:
|
|
186
|
-
e_1 = _b.sent();
|
|
187
|
-
eventConsumerMetrics_1.metrics.emit('event_error_total', { eventType: event.type });
|
|
188
|
-
consumerLogger.error("An error occured while consuming event ".concat(event.type), { event: event, error: e_1 });
|
|
189
|
-
throw e_1;
|
|
190
|
-
case 4:
|
|
191
|
-
eventConsumerMetrics_1.metrics.emit('event_duration_seconds_total', { eventType: event.type, phase: 'processing' }, new Date().getTime() - start);
|
|
192
|
-
eventConsumerMetrics_1.metrics.emit('event_duration_seconds', { eventType: event.type }, new Date().getTime() - start);
|
|
193
|
-
return [7 /*endfinally*/];
|
|
194
|
-
case 5:
|
|
195
|
-
eventConsumerMetrics_1.metrics.emit('event_success_total', { eventType: event.type });
|
|
196
|
-
consumerLogger.info("Event ".concat(event.type, " consumed"), { event: event });
|
|
197
|
-
_b.label = 6;
|
|
198
|
-
case 6: return [2 /*return*/];
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
};
|
|
203
|
-
__decorate([
|
|
204
|
-
(0, lockedDecorator_1.locked)(LOCK_NAMESPACE, { scope: 'instance' }),
|
|
205
|
-
__metadata("design:type", Function),
|
|
206
|
-
__metadata("design:paramtypes", []),
|
|
207
|
-
__metadata("design:returntype", Promise)
|
|
208
|
-
], AmqpEventConsumer.prototype, "listen", null);
|
|
209
|
-
__decorate([
|
|
210
|
-
(0, lockedDecorator_1.locked)(LOCK_NAMESPACE, { scope: 'instance' }),
|
|
211
|
-
__metadata("design:type", Function),
|
|
212
|
-
__metadata("design:paramtypes", []),
|
|
213
|
-
__metadata("design:returntype", Promise)
|
|
214
|
-
], AmqpEventConsumer.prototype, "close", null);
|
|
215
|
-
return AmqpEventConsumer;
|
|
216
|
-
}());
|
|
217
|
-
exports.AmqpEventConsumer = AmqpEventConsumer;
|
|
20
|
+
__exportStar(require("@signageos/amqp/dist/EventSourcing/EventConsumer/AmqpEventConsumer"), exports);
|
|
218
21
|
//# sourceMappingURL=AmqpEventConsumer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmqpEventConsumer.js","sourceRoot":"","sources":["../../../../src/AMQP/EventSourcing/EventConsumer/AmqpEventConsumer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AmqpEventConsumer.js","sourceRoot":"","sources":["../../../../src/AMQP/EventSourcing/EventConsumer/AmqpEventConsumer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,qGAAmF"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import { ZodObject } from 'zod';
|
|
2
|
-
import IEvent, { IEventPayload } from '../IEvent';
|
|
3
|
-
export type EventCallback<TPayload extends IEventPayload> = (event: IEvent<TPayload>) => Promise<void>;
|
|
4
|
-
export type EventOptions = {
|
|
5
|
-
schema?: ZodObject<any>;
|
|
6
|
-
};
|
|
7
1
|
/**
|
|
8
|
-
*
|
|
2
|
+
* @deprecated Use `@signageos/amqp` instead.
|
|
9
3
|
*/
|
|
10
|
-
export
|
|
11
|
-
/** Add a consumer for a specific event type */
|
|
12
|
-
addEventConsumer<TPayload extends IEventPayload>(eventType: string, callback: EventCallback<TPayload>, options?: EventOptions): void;
|
|
13
|
-
}
|
|
4
|
+
export * from '@signageos/amqp/dist/EventSourcing/EventConsumer/IEventConsumer';
|
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `@signageos/amqp` instead.
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("@signageos/amqp/dist/EventSourcing/EventConsumer/IEventConsumer"), exports);
|
|
3
21
|
//# sourceMappingURL=IEventConsumer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IEventConsumer.js","sourceRoot":"","sources":["../../../../src/AMQP/EventSourcing/EventConsumer/IEventConsumer.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"IEventConsumer.js","sourceRoot":"","sources":["../../../../src/AMQP/EventSourcing/EventConsumer/IEventConsumer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,kGAAgF"}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import IEvent, { IEventPayload } from '../IEvent';
|
|
2
|
-
import { EventCallback, IEventConsumer } from './IEventConsumer';
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Main use case is for testing so that the tests are not dependent on AMQP or other external services
|
|
2
|
+
* @deprecated Use `@signageos/amqp` instead.
|
|
7
3
|
*/
|
|
8
|
-
export
|
|
9
|
-
private emitter;
|
|
10
|
-
addEventConsumer<TPayload extends IEventPayload>(eventType: string, callback: EventCallback<TPayload>): Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* Will deliver the event to all consumers that were added via addEventConsumer
|
|
13
|
-
*/
|
|
14
|
-
emitEvent<TPayload extends IEventPayload>(event: IEvent<TPayload>): Promise<void>;
|
|
15
|
-
}
|
|
4
|
+
export * from '@signageos/amqp/dist/EventSourcing/EventConsumer/InMemoryEventConsumer';
|
|
@@ -1,76 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
36
7
|
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
15
|
};
|
|
38
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.InMemoryEventConsumer = void 0;
|
|
40
|
-
var AsyncEventEmitter_1 = require("../../../Events/AsyncEventEmitter");
|
|
41
17
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* Main use case is for testing so that the tests are not dependent on AMQP or other external services
|
|
18
|
+
* @deprecated Use `@signageos/amqp` instead.
|
|
45
19
|
*/
|
|
46
|
-
|
|
47
|
-
function InMemoryEventConsumer() {
|
|
48
|
-
this.emitter = new AsyncEventEmitter_1.AsyncEventEmitter();
|
|
49
|
-
}
|
|
50
|
-
InMemoryEventConsumer.prototype.addEventConsumer = function (eventType, callback) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
-
return __generator(this, function (_a) {
|
|
53
|
-
this.emitter.addListener(eventType, callback);
|
|
54
|
-
return [2 /*return*/];
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Will deliver the event to all consumers that were added via addEventConsumer
|
|
60
|
-
*/
|
|
61
|
-
InMemoryEventConsumer.prototype.emitEvent = function (event) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
switch (_a.label) {
|
|
65
|
-
case 0: return [4 /*yield*/, this.emitter.emit(event.type, event)];
|
|
66
|
-
case 1:
|
|
67
|
-
_a.sent();
|
|
68
|
-
return [2 /*return*/];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
return InMemoryEventConsumer;
|
|
74
|
-
}());
|
|
75
|
-
exports.InMemoryEventConsumer = InMemoryEventConsumer;
|
|
20
|
+
__exportStar(require("@signageos/amqp/dist/EventSourcing/EventConsumer/InMemoryEventConsumer"), exports);
|
|
76
21
|
//# sourceMappingURL=InMemoryEventConsumer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InMemoryEventConsumer.js","sourceRoot":"","sources":["../../../../src/AMQP/EventSourcing/EventConsumer/InMemoryEventConsumer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InMemoryEventConsumer.js","sourceRoot":"","sources":["../../../../src/AMQP/EventSourcing/EventConsumer/InMemoryEventConsumer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,yGAAuF"}
|
|
@@ -1,72 +1,5 @@
|
|
|
1
|
-
export interface IEventPayload<TType extends string = string> {
|
|
2
|
-
type: TType;
|
|
3
|
-
}
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
6
|
-
* It's a wrapper interface for a generic event payload.
|
|
7
|
-
* It contains all the necessary metadata for the event.
|
|
8
|
-
* This event is mostly used for event sourcing.
|
|
2
|
+
* @deprecated Use `@signageos/amqp` instead.
|
|
9
3
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* Unique identifier of the event.
|
|
13
|
-
* In MongoDB, it is stored as `_id` and is automatically generated.
|
|
14
|
-
*/
|
|
15
|
-
id: string;
|
|
16
|
-
/**
|
|
17
|
-
* Unique identifier of the command that caused the event.
|
|
18
|
-
* You can find it in {@link import("../CQRS/ICommand").id}.
|
|
19
|
-
*/
|
|
20
|
-
commandId: string;
|
|
21
|
-
/**
|
|
22
|
-
* Type of the event.
|
|
23
|
-
* It should be always the same as {@link IEventPayload['type']}.
|
|
24
|
-
*/
|
|
25
|
-
type: string;
|
|
26
|
-
/**
|
|
27
|
-
* Identifier of the source of the event.
|
|
28
|
-
* It's usually the same as the {@link import("../CQRS/ICommand").sourceUid}.
|
|
29
|
-
* It's usually used for logging and debugging.
|
|
30
|
-
* It can be used in some cases to identify the source of the event
|
|
31
|
-
* and to check if the event was dispatched by the same source as the command.
|
|
32
|
-
*/
|
|
33
|
-
sourceUid: string;
|
|
34
|
-
/**
|
|
35
|
-
* Date when the original command was dispatched.
|
|
36
|
-
* It's the same as {@link import("../CQRS/ICommand").receivedAt}.
|
|
37
|
-
* It can differ when the event is not produced by the command.
|
|
38
|
-
*/
|
|
39
|
-
dispatchedAt: Date;
|
|
40
|
-
/**
|
|
41
|
-
* Date when the event was received (written) to event store.
|
|
42
|
-
* This date is the most important date that should be used
|
|
43
|
-
* as a replacement for the `Date.now()` function.
|
|
44
|
-
* Since event sourcing is used as a source of truth,
|
|
45
|
-
* for consistency, all dates should be based on this date.
|
|
46
|
-
*/
|
|
47
|
-
receivedAt: Date;
|
|
48
|
-
/**
|
|
49
|
-
* All events are ordered by the `receivedAt` date.
|
|
50
|
-
* However, in some cases, there are multiple events emitted with the same `receivedAt` date.
|
|
51
|
-
* It's the case where a single command emits multiple events.
|
|
52
|
-
* In this case, the `secondaryIndex` is used to order the events.
|
|
53
|
-
* So it's the important part of the ordering of the events.
|
|
54
|
-
* See also {@link import("../CQRS/commandQueue").ITimestamp}.
|
|
55
|
-
*/
|
|
56
|
-
secondaryIndex: number;
|
|
57
|
-
/**
|
|
58
|
-
* Lock keys are used to identify affected domains of the event.
|
|
59
|
-
* It's used for specifying the dependencies between the events.
|
|
60
|
-
* Only those events within the same lock key are dependent on each other.
|
|
61
|
-
* So the order of the events is guaranteed only within the same lock key.
|
|
62
|
-
* Events with different lock keys can be processed in parallel.
|
|
63
|
-
*/
|
|
64
|
-
lockKeys: string[];
|
|
65
|
-
/**
|
|
66
|
-
* The generic payload of the event.
|
|
67
|
-
* The only required field is the `type` field.
|
|
68
|
-
* The `type` field should always be the same as the `type` field of the event.
|
|
69
|
-
*/
|
|
70
|
-
payload: TPayload;
|
|
71
|
-
}
|
|
72
|
-
export default IEvent;
|
|
4
|
+
export * from '@signageos/amqp/dist/EventSourcing/IEvent';
|
|
5
|
+
export { default } from '@signageos/amqp/dist/EventSourcing/IEvent';
|
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `@signageos/amqp` instead.
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("@signageos/amqp/dist/EventSourcing/IEvent"), exports);
|
|
3
21
|
//# sourceMappingURL=IEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IEvent.js","sourceRoot":"","sources":["../../../src/AMQP/EventSourcing/IEvent.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"IEvent.js","sourceRoot":"","sources":["../../../src/AMQP/EventSourcing/IEvent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,4EAA0D"}
|
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import { IDeferred } from '../../../Promise/deferred';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
* It allows to manage internal map of deferred promises for each lock-key.
|
|
2
|
+
* @deprecated Use `@signageos/amqp` instead.
|
|
5
3
|
*/
|
|
6
|
-
export
|
|
7
|
-
private deferredMap;
|
|
8
|
-
/**
|
|
9
|
-
* Create a deferred for the current lock-keys and push it to the list for subsequent promises to wait on.
|
|
10
|
-
*/
|
|
11
|
-
addDeferred(lockKeys: string[]): IDeferred<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Remove the deferred from the list for the given lock-keys.
|
|
14
|
-
* If the list becomes empty, remove it from the map (cleanup).
|
|
15
|
-
*/
|
|
16
|
-
removeDeferred(lockKeys: string[], deferred: IDeferred<void>): void;
|
|
17
|
-
/**
|
|
18
|
-
* Get a list of promises for all previously created deferred with the same lock-keys.
|
|
19
|
-
*/
|
|
20
|
-
getPreviousPromises(lockKeys: string[]): Promise<void>[];
|
|
21
|
-
}
|
|
4
|
+
export * from '@signageos/amqp/dist/EventSourcing/Locked/deferredState';
|
|
@@ -1,72 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4
15
|
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DeferredState = void 0;
|
|
7
|
-
var deferred_1 = require("../../../Promise/deferred");
|
|
8
|
-
var debug_1 = __importDefault(require("debug"));
|
|
9
|
-
var debug = (0, debug_1.default)('@signageos/lib:AMQP:EventSourcing:Locked:deferredState');
|
|
10
17
|
/**
|
|
11
|
-
*
|
|
12
|
-
* It allows to manage internal map of deferred promises for each lock-key.
|
|
18
|
+
* @deprecated Use `@signageos/amqp` instead.
|
|
13
19
|
*/
|
|
14
|
-
|
|
15
|
-
function DeferredState() {
|
|
16
|
-
this.deferredMap = new Map();
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Create a deferred for the current lock-keys and push it to the list for subsequent promises to wait on.
|
|
20
|
-
*/
|
|
21
|
-
DeferredState.prototype.addDeferred = function (lockKeys) {
|
|
22
|
-
var _a;
|
|
23
|
-
debug('Adding deferred for lock-keys', { lockKeys: lockKeys });
|
|
24
|
-
var currentDeferred = (0, deferred_1.createDeferred)(true);
|
|
25
|
-
for (var _i = 0, lockKeys_1 = lockKeys; _i < lockKeys_1.length; _i++) {
|
|
26
|
-
var lockKey = lockKeys_1[_i];
|
|
27
|
-
var listOfDeferred = (_a = this.deferredMap.get(lockKey)) !== null && _a !== void 0 ? _a : [];
|
|
28
|
-
this.deferredMap.set(lockKey, listOfDeferred);
|
|
29
|
-
listOfDeferred.push(currentDeferred);
|
|
30
|
-
}
|
|
31
|
-
return currentDeferred;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Remove the deferred from the list for the given lock-keys.
|
|
35
|
-
* If the list becomes empty, remove it from the map (cleanup).
|
|
36
|
-
*/
|
|
37
|
-
DeferredState.prototype.removeDeferred = function (lockKeys, deferred) {
|
|
38
|
-
var _a;
|
|
39
|
-
debug('Removing deferred for lock-keys', { lockKeys: lockKeys });
|
|
40
|
-
for (var _i = 0, lockKeys_2 = lockKeys; _i < lockKeys_2.length; _i++) {
|
|
41
|
-
var lockKey = lockKeys_2[_i];
|
|
42
|
-
var listOfDeferred = (_a = this.deferredMap.get(lockKey)) !== null && _a !== void 0 ? _a : [];
|
|
43
|
-
var index = listOfDeferred.indexOf(deferred);
|
|
44
|
-
if (index !== -1) {
|
|
45
|
-
listOfDeferred.splice(index, 1);
|
|
46
|
-
}
|
|
47
|
-
if (listOfDeferred.length === 0) {
|
|
48
|
-
this.deferredMap.delete(lockKey);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Get a list of promises for all previously created deferred with the same lock-keys.
|
|
54
|
-
*/
|
|
55
|
-
DeferredState.prototype.getPreviousPromises = function (lockKeys) {
|
|
56
|
-
var _a;
|
|
57
|
-
var promises = [];
|
|
58
|
-
for (var _i = 0, lockKeys_3 = lockKeys; _i < lockKeys_3.length; _i++) {
|
|
59
|
-
var lockKey = lockKeys_3[_i];
|
|
60
|
-
var listOfDeferred = (_a = this.deferredMap.get(lockKey)) !== null && _a !== void 0 ? _a : [];
|
|
61
|
-
for (var _b = 0, listOfDeferred_1 = listOfDeferred; _b < listOfDeferred_1.length; _b++) {
|
|
62
|
-
var deferred = listOfDeferred_1[_b];
|
|
63
|
-
promises.push(deferred.promise);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
debug('Getting previous promises for lock-keys', { lockKeys: lockKeys, count: promises.length });
|
|
67
|
-
return promises;
|
|
68
|
-
};
|
|
69
|
-
return DeferredState;
|
|
70
|
-
}());
|
|
71
|
-
exports.DeferredState = DeferredState;
|
|
20
|
+
__exportStar(require("@signageos/amqp/dist/EventSourcing/Locked/deferredState"), exports);
|
|
72
21
|
//# sourceMappingURL=deferredState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deferredState.js","sourceRoot":"","sources":["../../../../src/AMQP/EventSourcing/Locked/deferredState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deferredState.js","sourceRoot":"","sources":["../../../../src/AMQP/EventSourcing/Locked/deferredState.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,0FAAwE"}
|