@nestjs-transactional/outbox 1.1.0 → 2.0.0
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 +14 -0
- package/dist/api/completed-event-publications.d.ts +2 -2
- package/dist/api/completed-event-publications.js +6 -9
- package/dist/api/completed-event-publications.js.map +1 -1
- package/dist/api/failed-event-publications.d.ts +3 -3
- package/dist/api/failed-event-publications.js +10 -13
- package/dist/api/failed-event-publications.js.map +1 -1
- package/dist/api/incomplete-event-publications.d.ts +3 -3
- package/dist/api/incomplete-event-publications.js +11 -14
- package/dist/api/incomplete-event-publications.js.map +1 -1
- package/dist/decorators/inject-decorators.js +12 -24
- package/dist/decorators/inject-decorators.js.map +1 -1
- package/dist/decorators/outbox-events-handler.decorator.js +6 -11
- package/dist/decorators/outbox-events-handler.decorator.js.map +1 -1
- package/dist/dispatcher/data-source-outbox-publisher.d.ts +2 -2
- package/dist/dispatcher/data-source-outbox-publisher.js +7 -11
- package/dist/dispatcher/data-source-outbox-publisher.js.map +1 -1
- package/dist/dispatcher/event-publication-processor.d.ts +5 -5
- package/dist/dispatcher/event-publication-processor.js +18 -21
- package/dist/dispatcher/event-publication-processor.js.map +1 -1
- package/dist/dispatcher/outbox-event-publisher.js +16 -19
- package/dist/dispatcher/outbox-event-publisher.js.map +1 -1
- package/dist/dispatcher/processor-options.d.ts +1 -1
- package/dist/dispatcher/processor-options.js +5 -8
- package/dist/dispatcher/processor-options.js.map +1 -1
- package/dist/externalization/describe-thrown.js +1 -4
- package/dist/externalization/describe-thrown.js.map +1 -1
- package/dist/externalization/errors.d.ts +1 -1
- package/dist/externalization/errors.js +2 -6
- package/dist/externalization/errors.js.map +1 -1
- package/dist/externalization/event-externalizer.d.ts +1 -1
- package/dist/externalization/event-externalizer.js +1 -4
- package/dist/externalization/event-externalizer.js.map +1 -1
- package/dist/externalization/externalization-registry.d.ts +3 -3
- package/dist/externalization/externalization-registry.js +10 -13
- package/dist/externalization/externalization-registry.js.map +1 -1
- package/dist/externalization/externalized.decorator.js +6 -11
- package/dist/externalization/externalized.decorator.js.map +1 -1
- package/dist/externalization/types.js +1 -2
- package/dist/index.d.ts +43 -43
- package/dist/index.js +39 -65
- package/dist/index.js.map +1 -1
- package/dist/interfaces/outbox-event-handler.interface.js +1 -2
- package/dist/module/outbox-processing.module.d.ts +1 -1
- package/dist/module/outbox-processing.module.js +6 -9
- package/dist/module/outbox-processing.module.js.map +1 -1
- package/dist/module/outbox.module.d.ts +10 -10
- package/dist/module/outbox.module.js +145 -148
- package/dist/module/outbox.module.js.map +1 -1
- package/dist/recovery/outbox-cleanup-scheduler.d.ts +2 -2
- package/dist/recovery/outbox-cleanup-scheduler.js +7 -10
- package/dist/recovery/outbox-cleanup-scheduler.js.map +1 -1
- package/dist/recovery/outbox-retry-scheduler.d.ts +2 -2
- package/dist/recovery/outbox-retry-scheduler.js +11 -14
- package/dist/recovery/outbox-retry-scheduler.js.map +1 -1
- package/dist/recovery/staleness-monitor.d.ts +2 -2
- package/dist/recovery/staleness-monitor.js +14 -17
- package/dist/recovery/staleness-monitor.js.map +1 -1
- package/dist/recovery/startup-recovery.d.ts +1 -1
- package/dist/recovery/startup-recovery.js +11 -14
- package/dist/recovery/startup-recovery.js.map +1 -1
- package/dist/registry/event-publication-registry.d.ts +4 -4
- package/dist/registry/event-publication-registry.js +17 -20
- package/dist/registry/event-publication-registry.js.map +1 -1
- package/dist/registry/listener-registry.js +6 -9
- package/dist/registry/listener-registry.js.map +1 -1
- package/dist/registry/multi-ds-listener-registrar.d.ts +1 -1
- package/dist/registry/multi-ds-listener-registrar.js +15 -18
- package/dist/registry/multi-ds-listener-registrar.js.map +1 -1
- package/dist/registry/outbox-listener-scanner.d.ts +1 -1
- package/dist/registry/outbox-listener-scanner.js +23 -27
- package/dist/registry/outbox-listener-scanner.js.map +1 -1
- package/dist/repository/event-publication-repository.d.ts +2 -2
- package/dist/repository/event-publication-repository.js +1 -4
- package/dist/repository/event-publication-repository.js.map +1 -1
- package/dist/serialization/event-serializer.js +1 -4
- package/dist/serialization/event-serializer.js.map +1 -1
- package/dist/serialization/event-type-registry.js +5 -8
- package/dist/serialization/event-type-registry.js.map +1 -1
- package/dist/serialization/event-type-resolver.d.ts +1 -1
- package/dist/serialization/event-type-resolver.js +4 -7
- package/dist/serialization/event-type-resolver.js.map +1 -1
- package/dist/serialization/json-event-serializer.d.ts +2 -2
- package/dist/serialization/json-event-serializer.js +10 -13
- package/dist/serialization/json-event-serializer.js.map +1 -1
- package/dist/shutdown/drain.js +2 -6
- package/dist/shutdown/drain.js.map +1 -1
- package/dist/testing/assertable-published-events.d.ts +1 -1
- package/dist/testing/assertable-published-events.js +8 -13
- package/dist/testing/assertable-published-events.js.map +1 -1
- package/dist/testing/in-memory-repository.d.ts +3 -3
- package/dist/testing/in-memory-repository.js +22 -25
- package/dist/testing/in-memory-repository.js.map +1 -1
- package/dist/testing/index.d.ts +3 -3
- package/dist/testing/index.js +3 -19
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/published-events.d.ts +3 -3
- package/dist/testing/published-events.js +9 -13
- package/dist/testing/published-events.js.map +1 -1
- package/dist/tokens/index.d.ts +1 -1
- package/dist/tokens/index.js +1 -13
- package/dist/tokens/index.js.map +1 -1
- package/dist/tokens/token-utils.js +10 -21
- package/dist/tokens/token-utils.js.map +1 -1
- package/dist/types/cleanup-config.js +3 -6
- package/dist/types/cleanup-config.js.map +1 -1
- package/dist/types/completion-mode.js +2 -5
- package/dist/types/completion-mode.js.map +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/errors.js +7 -16
- package/dist/types/errors.js.map +1 -1
- package/dist/types/event-publication.d.ts +1 -1
- package/dist/types/event-publication.js +1 -2
- package/dist/types/publication-status.js +2 -5
- package/dist/types/publication-status.js.map +1 -1
- package/dist/types/resubmission-options.d.ts +1 -1
- package/dist/types/resubmission-options.js +1 -5
- package/dist/types/resubmission-options.js.map +1 -1
- package/dist/types/retry-config.js +3 -6
- package/dist/types/retry-config.js.map +1 -1
- package/dist/types/staleness-config.js +3 -6
- package/dist/types/staleness-config.js.map +1 -1
- package/package.json +13 -12
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -6,66 +5,64 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
7
|
var OutboxModule_1;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const retry_config_1 = require("../types/retry-config");
|
|
39
|
-
const staleness_config_1 = require("../types/staleness-config");
|
|
8
|
+
import { Module, } from '@nestjs/common';
|
|
9
|
+
import { DiscoveryModule, ModuleRef } from '@nestjs/core';
|
|
10
|
+
import { TransactionManager } from '@nestjs-transactional/core';
|
|
11
|
+
import { CompletedEventPublications } from '../api/completed-event-publications.js';
|
|
12
|
+
import { FailedEventPublications } from '../api/failed-event-publications.js';
|
|
13
|
+
import { IncompleteEventPublications } from '../api/incomplete-event-publications.js';
|
|
14
|
+
import { DataSourceOutboxPublisher } from '../dispatcher/data-source-outbox-publisher.js';
|
|
15
|
+
import { EventPublicationProcessor } from '../dispatcher/event-publication-processor.js';
|
|
16
|
+
import { OUTBOX_DATA_SOURCE_NAMES, OutboxEventPublisher, } from '../dispatcher/outbox-event-publisher.js';
|
|
17
|
+
import { DEFAULT_PROCESSOR_OPTIONS, } from '../dispatcher/processor-options.js';
|
|
18
|
+
import { EVENT_EXTERNALIZER, } from '../externalization/event-externalizer.js';
|
|
19
|
+
import { ExternalizationRegistry } from '../externalization/externalization-registry.js';
|
|
20
|
+
import { OutboxCleanupScheduler } from '../recovery/outbox-cleanup-scheduler.js';
|
|
21
|
+
import { OutboxRetryScheduler } from '../recovery/outbox-retry-scheduler.js';
|
|
22
|
+
import { StalenessMonitor } from '../recovery/staleness-monitor.js';
|
|
23
|
+
import { OUTBOX_RECOVERY_OPTIONS, StartupRecoveryService, } from '../recovery/startup-recovery.js';
|
|
24
|
+
import { EventPublicationRegistry } from '../registry/event-publication-registry.js';
|
|
25
|
+
import { OutboxListenerRegistry } from '../registry/listener-registry.js';
|
|
26
|
+
import { MultiDsOutboxListenerRegistrar, OUTBOX_LISTENER_REGISTRAR_TOKEN, } from '../registry/multi-ds-listener-registrar.js';
|
|
27
|
+
import { OutboxListenerScanner } from '../registry/outbox-listener-scanner.js';
|
|
28
|
+
import { EVENT_PUBLICATION_REPOSITORY, } from '../repository/event-publication-repository.js';
|
|
29
|
+
import { EVENT_SERIALIZER } from '../serialization/event-serializer.js';
|
|
30
|
+
import { EVENT_TYPE_REGISTRY, EventTypeRegistry } from '../serialization/event-type-registry.js';
|
|
31
|
+
import { JsonEventSerializer } from '../serialization/json-event-serializer.js';
|
|
32
|
+
import { InMemoryEventPublicationRepository } from '../testing/in-memory-repository.js';
|
|
33
|
+
import { getEventPublicationProcessorToken, getEventPublicationRegistryToken, getEventPublicationRepositoryToken, getEventTypeRegistryToken, getExternalizationRegistryToken, getOutboxEventSerializerToken, getOutboxListenerRegistryToken, getOutboxPublisherToken, } from '../tokens/token-utils.js';
|
|
34
|
+
import { DEFAULT_CLEANUP_CONFIG } from '../types/cleanup-config.js';
|
|
35
|
+
import { DEFAULT_RETRY_CONFIG } from '../types/retry-config.js';
|
|
36
|
+
import { DEFAULT_STALENESS_CONFIG } from '../types/staleness-config.js';
|
|
40
37
|
const DEFAULT_DATA_SOURCE = 'default';
|
|
41
38
|
/** DI token carrying the resolved {@link EventPublicationProcessorOptions}. */
|
|
42
|
-
|
|
39
|
+
export const OUTBOX_PROCESSOR_OPTIONS = Symbol('OUTBOX_PROCESSOR_OPTIONS');
|
|
43
40
|
/** DI token carrying the resolved {@link StalenessConfig}. */
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
export const OUTBOX_STALENESS_CONFIG = Symbol('OUTBOX_STALENESS_CONFIG');
|
|
42
|
+
export const OUTBOX_RETRY_CONFIG = Symbol('OUTBOX_RETRY_CONFIG');
|
|
46
43
|
/**
|
|
47
44
|
* Bundle of per-dataSource processors and monitors that
|
|
48
45
|
* {@link OutboxProcessingModule} reads on bootstrap to start every
|
|
49
46
|
* configured outbox loop. Provided by `forRoot` so the processing
|
|
50
47
|
* module needs no per-dataSource configuration of its own.
|
|
51
48
|
*/
|
|
52
|
-
|
|
49
|
+
export const OUTBOX_PROCESSING_BUNDLE = Symbol('OUTBOX_PROCESSING_BUNDLE');
|
|
53
50
|
const ASYNC_OPTIONS_TOKEN = (ds) => Symbol(`OUTBOX_ASYNC_OPTIONS[${ds}]`);
|
|
54
51
|
function resolveProcessorOptions(processor, completionMode) {
|
|
55
52
|
return {
|
|
56
|
-
...
|
|
53
|
+
...DEFAULT_PROCESSOR_OPTIONS,
|
|
57
54
|
...processor,
|
|
58
|
-
completionMode: completionMode ?? processor?.completionMode ??
|
|
55
|
+
completionMode: completionMode ?? processor?.completionMode ?? DEFAULT_PROCESSOR_OPTIONS.completionMode,
|
|
59
56
|
};
|
|
60
57
|
}
|
|
61
58
|
function resolveStalenessConfig(staleness) {
|
|
62
|
-
return { ...
|
|
59
|
+
return { ...DEFAULT_STALENESS_CONFIG, ...staleness };
|
|
63
60
|
}
|
|
64
61
|
function resolveRetryConfig(retry) {
|
|
65
|
-
return { ...
|
|
62
|
+
return { ...DEFAULT_RETRY_CONFIG, ...retry };
|
|
66
63
|
}
|
|
67
64
|
function resolveCleanupConfig(cleanup) {
|
|
68
|
-
return { ...
|
|
65
|
+
return { ...DEFAULT_CLEANUP_CONFIG, ...cleanup };
|
|
69
66
|
}
|
|
70
67
|
function resolveRecoveryOptions(republishOnStartup, startupBatchSize) {
|
|
71
68
|
return {
|
|
@@ -164,9 +161,9 @@ let OutboxModule = class OutboxModule {
|
|
|
164
161
|
const exportTokens = [...perDataSourceExports(ds)];
|
|
165
162
|
if (ds === DEFAULT_DATA_SOURCE) {
|
|
166
163
|
providers.push(...buildDefaultDataSourceAliases());
|
|
167
|
-
providers.push(
|
|
164
|
+
providers.push(FailedEventPublications, IncompleteEventPublications, CompletedEventPublications, StartupRecoveryService);
|
|
168
165
|
exportTokens.push(...defaultDataSourceAliasTokens());
|
|
169
|
-
exportTokens.push(
|
|
166
|
+
exportTokens.push(FailedEventPublications, IncompleteEventPublications, CompletedEventPublications, StartupRecoveryService);
|
|
170
167
|
}
|
|
171
168
|
if (isFirstRegistration) {
|
|
172
169
|
// Process-wide singletons. Their factories close over this
|
|
@@ -175,17 +172,17 @@ let OutboxModule = class OutboxModule {
|
|
|
175
172
|
// (forRoot bodies run synchronously at module-definition time).
|
|
176
173
|
providers.push(...buildFacadePublisherProvider(OutboxModule_1));
|
|
177
174
|
providers.push(buildProcessingBundleProvider(OutboxModule_1));
|
|
178
|
-
providers.push(
|
|
175
|
+
providers.push(OutboxListenerScanner);
|
|
179
176
|
providers.push(...buildMultiDsRegistrarProviders());
|
|
180
|
-
exportTokens.push(
|
|
181
|
-
exportTokens.push(
|
|
182
|
-
exportTokens.push(
|
|
183
|
-
exportTokens.push(
|
|
177
|
+
exportTokens.push(OutboxEventPublisher);
|
|
178
|
+
exportTokens.push(OUTBOX_PROCESSING_BUNDLE);
|
|
179
|
+
exportTokens.push(MultiDsOutboxListenerRegistrar);
|
|
180
|
+
exportTokens.push(OUTBOX_LISTENER_REGISTRAR_TOKEN);
|
|
184
181
|
}
|
|
185
182
|
return {
|
|
186
183
|
module: OutboxModule_1,
|
|
187
184
|
global: options.isGlobal ?? true,
|
|
188
|
-
imports: [
|
|
185
|
+
imports: [DiscoveryModule],
|
|
189
186
|
providers,
|
|
190
187
|
exports: exportTokens,
|
|
191
188
|
};
|
|
@@ -222,14 +219,14 @@ let OutboxModule = class OutboxModule {
|
|
|
222
219
|
useFactory: options.useFactory,
|
|
223
220
|
inject: options.inject ? [...options.inject] : undefined,
|
|
224
221
|
};
|
|
225
|
-
const eventTypeRegistryToken =
|
|
226
|
-
const repositoryToken =
|
|
227
|
-
const serializerToken =
|
|
228
|
-
const listenerRegistryToken =
|
|
229
|
-
const publicationRegistryToken =
|
|
230
|
-
const externalizationRegistryToken =
|
|
231
|
-
const processorToken =
|
|
232
|
-
const publisherToken =
|
|
222
|
+
const eventTypeRegistryToken = getEventTypeRegistryToken(ds);
|
|
223
|
+
const repositoryToken = getEventPublicationRepositoryToken(ds);
|
|
224
|
+
const serializerToken = getOutboxEventSerializerToken(ds);
|
|
225
|
+
const listenerRegistryToken = getOutboxListenerRegistryToken(ds);
|
|
226
|
+
const publicationRegistryToken = getEventPublicationRegistryToken(ds);
|
|
227
|
+
const externalizationRegistryToken = getExternalizationRegistryToken(ds);
|
|
228
|
+
const processorToken = getEventPublicationProcessorToken(ds);
|
|
229
|
+
const publisherToken = getOutboxPublisherToken(ds);
|
|
233
230
|
const stalenessToken = perDsStalenessMonitorToken(ds);
|
|
234
231
|
const recoveryToken = perDsStartupRecoveryToken(ds);
|
|
235
232
|
const processorOptionsToken = perDsProcessorOptionsToken(ds);
|
|
@@ -243,30 +240,30 @@ let OutboxModule = class OutboxModule {
|
|
|
243
240
|
asyncOptionsProvider,
|
|
244
241
|
{
|
|
245
242
|
provide: eventTypeRegistryToken,
|
|
246
|
-
useFactory: () => new
|
|
243
|
+
useFactory: () => new EventTypeRegistry(),
|
|
247
244
|
},
|
|
248
245
|
options.repository
|
|
249
246
|
? reBindProvider(options.repository, repositoryToken)
|
|
250
|
-
: { provide: repositoryToken, useClass:
|
|
247
|
+
: { provide: repositoryToken, useClass: InMemoryEventPublicationRepository },
|
|
251
248
|
options.serializer
|
|
252
249
|
? reBindProvider(options.serializer, serializerToken)
|
|
253
250
|
: {
|
|
254
251
|
provide: serializerToken,
|
|
255
|
-
useFactory: (registry) => new
|
|
252
|
+
useFactory: (registry) => new JsonEventSerializer(registry),
|
|
256
253
|
inject: [eventTypeRegistryToken],
|
|
257
254
|
},
|
|
258
255
|
{
|
|
259
256
|
provide: listenerRegistryToken,
|
|
260
|
-
useFactory: () => new
|
|
257
|
+
useFactory: () => new OutboxListenerRegistry(),
|
|
261
258
|
},
|
|
262
259
|
{
|
|
263
260
|
provide: publicationRegistryToken,
|
|
264
|
-
useFactory: (repo, serializer) => new
|
|
261
|
+
useFactory: (repo, serializer) => new EventPublicationRegistry(repo, serializer),
|
|
265
262
|
inject: [repositoryToken, serializerToken],
|
|
266
263
|
},
|
|
267
264
|
{
|
|
268
265
|
provide: externalizationRegistryToken,
|
|
269
|
-
useFactory: (etr) => new
|
|
266
|
+
useFactory: (etr) => new ExternalizationRegistry(etr),
|
|
270
267
|
inject: [eventTypeRegistryToken],
|
|
271
268
|
},
|
|
272
269
|
{
|
|
@@ -276,12 +273,12 @@ let OutboxModule = class OutboxModule {
|
|
|
276
273
|
},
|
|
277
274
|
{
|
|
278
275
|
provide: processorToken,
|
|
279
|
-
useFactory: (registry, listeners, opts, externalizer, externalizationRegistry) => new
|
|
276
|
+
useFactory: (registry, listeners, opts, externalizer, externalizationRegistry) => new EventPublicationProcessor(registry, listeners, opts, externalizer, externalizationRegistry),
|
|
280
277
|
inject: [
|
|
281
278
|
publicationRegistryToken,
|
|
282
279
|
listenerRegistryToken,
|
|
283
280
|
processorOptionsToken,
|
|
284
|
-
{ token:
|
|
281
|
+
{ token: EVENT_EXTERNALIZER, optional: true },
|
|
285
282
|
externalizationRegistryToken,
|
|
286
283
|
],
|
|
287
284
|
},
|
|
@@ -292,7 +289,7 @@ let OutboxModule = class OutboxModule {
|
|
|
292
289
|
},
|
|
293
290
|
{
|
|
294
291
|
provide: stalenessToken,
|
|
295
|
-
useFactory: (repo, cfg) => new
|
|
292
|
+
useFactory: (repo, cfg) => new StalenessMonitor(repo, cfg),
|
|
296
293
|
inject: [repositoryToken, stalenessConfigToken],
|
|
297
294
|
},
|
|
298
295
|
{
|
|
@@ -305,7 +302,7 @@ let OutboxModule = class OutboxModule {
|
|
|
305
302
|
useFactory: (repo, cfg) =>
|
|
306
303
|
// Built on a per-DS `FailedEventPublications` rather than the
|
|
307
304
|
// class-token one, which is bound to the default dataSource.
|
|
308
|
-
new
|
|
305
|
+
new OutboxRetryScheduler(new FailedEventPublications(repo), cfg),
|
|
309
306
|
inject: [repositoryToken, retryConfigToken],
|
|
310
307
|
},
|
|
311
308
|
{
|
|
@@ -315,7 +312,7 @@ let OutboxModule = class OutboxModule {
|
|
|
315
312
|
},
|
|
316
313
|
{
|
|
317
314
|
provide: cleanupToken,
|
|
318
|
-
useFactory: (repo, cfg) => new
|
|
315
|
+
useFactory: (repo, cfg) => new OutboxCleanupScheduler(repo, cfg),
|
|
319
316
|
inject: [repositoryToken, cleanupConfigToken],
|
|
320
317
|
},
|
|
321
318
|
{
|
|
@@ -325,30 +322,30 @@ let OutboxModule = class OutboxModule {
|
|
|
325
322
|
},
|
|
326
323
|
{
|
|
327
324
|
provide: publisherToken,
|
|
328
|
-
useFactory: (publicationRegistry, listenerRegistry) => new
|
|
325
|
+
useFactory: (publicationRegistry, listenerRegistry) => new DataSourceOutboxPublisher(ds, publicationRegistry, listenerRegistry),
|
|
329
326
|
inject: [publicationRegistryToken, listenerRegistryToken],
|
|
330
327
|
},
|
|
331
328
|
];
|
|
332
329
|
const exportTokens = [...perDataSourceExports(ds)];
|
|
333
330
|
if (ds === DEFAULT_DATA_SOURCE) {
|
|
334
|
-
providers.push({ provide: recoveryToken, useExisting:
|
|
331
|
+
providers.push({ provide: recoveryToken, useExisting: StartupRecoveryService }, ...buildDefaultDataSourceAliases(), FailedEventPublications, IncompleteEventPublications, CompletedEventPublications, StartupRecoveryService);
|
|
335
332
|
exportTokens.push(...defaultDataSourceAliasTokens());
|
|
336
|
-
exportTokens.push(
|
|
333
|
+
exportTokens.push(FailedEventPublications, IncompleteEventPublications, CompletedEventPublications, StartupRecoveryService);
|
|
337
334
|
}
|
|
338
335
|
if (isFirstRegistration) {
|
|
339
336
|
providers.push(...buildFacadePublisherProvider(OutboxModule_1));
|
|
340
337
|
providers.push(buildProcessingBundleProvider(OutboxModule_1));
|
|
341
|
-
providers.push(
|
|
338
|
+
providers.push(OutboxListenerScanner);
|
|
342
339
|
providers.push(...buildMultiDsRegistrarProviders());
|
|
343
|
-
exportTokens.push(
|
|
344
|
-
exportTokens.push(
|
|
345
|
-
exportTokens.push(
|
|
346
|
-
exportTokens.push(
|
|
340
|
+
exportTokens.push(OutboxEventPublisher);
|
|
341
|
+
exportTokens.push(OUTBOX_PROCESSING_BUNDLE);
|
|
342
|
+
exportTokens.push(MultiDsOutboxListenerRegistrar);
|
|
343
|
+
exportTokens.push(OUTBOX_LISTENER_REGISTRAR_TOKEN);
|
|
347
344
|
}
|
|
348
345
|
return {
|
|
349
346
|
module: OutboxModule_1,
|
|
350
347
|
global: options.isGlobal ?? true,
|
|
351
|
-
imports: [
|
|
348
|
+
imports: [DiscoveryModule, ...(options.imports ?? [])],
|
|
352
349
|
providers,
|
|
353
350
|
exports: exportTokens,
|
|
354
351
|
};
|
|
@@ -399,16 +396,16 @@ let OutboxModule = class OutboxModule {
|
|
|
399
396
|
}
|
|
400
397
|
return true;
|
|
401
398
|
},
|
|
402
|
-
inject: [
|
|
399
|
+
inject: [getEventTypeRegistryToken(dataSource)],
|
|
403
400
|
},
|
|
404
401
|
],
|
|
405
402
|
};
|
|
406
403
|
}
|
|
407
404
|
};
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
(0, common_1.Module)({})
|
|
405
|
+
OutboxModule = OutboxModule_1 = __decorate([
|
|
406
|
+
Module({})
|
|
411
407
|
], OutboxModule);
|
|
408
|
+
export { OutboxModule };
|
|
412
409
|
// ---------------------------------------------------------------------------
|
|
413
410
|
// Per-dataSource provider helpers
|
|
414
411
|
// ---------------------------------------------------------------------------
|
|
@@ -440,14 +437,14 @@ function perDsCleanupConfigToken(ds) {
|
|
|
440
437
|
return `${ds}OutboxCleanupConfig`;
|
|
441
438
|
}
|
|
442
439
|
function buildPerDataSourceProviders(ds, repository, serializer, processorOpts, stalenessCfg, recoveryOpts, retryCfg, cleanupCfg) {
|
|
443
|
-
const eventTypeRegistryToken =
|
|
444
|
-
const repositoryToken =
|
|
445
|
-
const serializerToken =
|
|
446
|
-
const listenerRegistryToken =
|
|
447
|
-
const publicationRegistryToken =
|
|
448
|
-
const externalizationRegistryToken =
|
|
449
|
-
const processorToken =
|
|
450
|
-
const publisherToken =
|
|
440
|
+
const eventTypeRegistryToken = getEventTypeRegistryToken(ds);
|
|
441
|
+
const repositoryToken = getEventPublicationRepositoryToken(ds);
|
|
442
|
+
const serializerToken = getOutboxEventSerializerToken(ds);
|
|
443
|
+
const listenerRegistryToken = getOutboxListenerRegistryToken(ds);
|
|
444
|
+
const publicationRegistryToken = getEventPublicationRegistryToken(ds);
|
|
445
|
+
const externalizationRegistryToken = getExternalizationRegistryToken(ds);
|
|
446
|
+
const processorToken = getEventPublicationProcessorToken(ds);
|
|
447
|
+
const publisherToken = getOutboxPublisherToken(ds);
|
|
451
448
|
const stalenessToken = perDsStalenessMonitorToken(ds);
|
|
452
449
|
const recoveryToken = perDsStartupRecoveryToken(ds);
|
|
453
450
|
const processorOptionsToken = perDsProcessorOptionsToken(ds);
|
|
@@ -460,48 +457,48 @@ function buildPerDataSourceProviders(ds, repository, serializer, processorOpts,
|
|
|
460
457
|
return [
|
|
461
458
|
{
|
|
462
459
|
provide: eventTypeRegistryToken,
|
|
463
|
-
useFactory: () => new
|
|
460
|
+
useFactory: () => new EventTypeRegistry(),
|
|
464
461
|
},
|
|
465
462
|
repository
|
|
466
463
|
? reBindProvider(repository, repositoryToken)
|
|
467
|
-
: { provide: repositoryToken, useClass:
|
|
464
|
+
: { provide: repositoryToken, useClass: InMemoryEventPublicationRepository },
|
|
468
465
|
serializer
|
|
469
466
|
? reBindProvider(serializer, serializerToken)
|
|
470
467
|
: {
|
|
471
468
|
provide: serializerToken,
|
|
472
|
-
useFactory: (registry) => new
|
|
469
|
+
useFactory: (registry) => new JsonEventSerializer(registry),
|
|
473
470
|
inject: [eventTypeRegistryToken],
|
|
474
471
|
},
|
|
475
472
|
{
|
|
476
473
|
provide: listenerRegistryToken,
|
|
477
|
-
useFactory: () => new
|
|
474
|
+
useFactory: () => new OutboxListenerRegistry(),
|
|
478
475
|
},
|
|
479
476
|
{
|
|
480
477
|
provide: publicationRegistryToken,
|
|
481
|
-
useFactory: (repo, s) => new
|
|
478
|
+
useFactory: (repo, s) => new EventPublicationRegistry(repo, s),
|
|
482
479
|
inject: [repositoryToken, serializerToken],
|
|
483
480
|
},
|
|
484
481
|
{
|
|
485
482
|
provide: externalizationRegistryToken,
|
|
486
|
-
useFactory: (etr) => new
|
|
483
|
+
useFactory: (etr) => new ExternalizationRegistry(etr),
|
|
487
484
|
inject: [eventTypeRegistryToken],
|
|
488
485
|
},
|
|
489
486
|
{ provide: processorOptionsToken, useValue: processorOpts },
|
|
490
487
|
{
|
|
491
488
|
provide: processorToken,
|
|
492
|
-
useFactory: (registry, listeners, opts, externalizer, externalizationRegistry) => new
|
|
489
|
+
useFactory: (registry, listeners, opts, externalizer, externalizationRegistry) => new EventPublicationProcessor(registry, listeners, opts, externalizer, externalizationRegistry),
|
|
493
490
|
inject: [
|
|
494
491
|
publicationRegistryToken,
|
|
495
492
|
listenerRegistryToken,
|
|
496
493
|
processorOptionsToken,
|
|
497
|
-
{ token:
|
|
494
|
+
{ token: EVENT_EXTERNALIZER, optional: true },
|
|
498
495
|
externalizationRegistryToken,
|
|
499
496
|
],
|
|
500
497
|
},
|
|
501
498
|
{ provide: stalenessConfigToken, useValue: stalenessCfg },
|
|
502
499
|
{
|
|
503
500
|
provide: stalenessToken,
|
|
504
|
-
useFactory: (repo, cfg) => new
|
|
501
|
+
useFactory: (repo, cfg) => new StalenessMonitor(repo, cfg),
|
|
505
502
|
inject: [repositoryToken, stalenessConfigToken],
|
|
506
503
|
},
|
|
507
504
|
{ provide: retryConfigToken, useValue: retryCfg },
|
|
@@ -510,13 +507,13 @@ function buildPerDataSourceProviders(ds, repository, serializer, processorOpts,
|
|
|
510
507
|
useFactory: (repo, cfg) =>
|
|
511
508
|
// Built on a per-DS `FailedEventPublications` rather than the
|
|
512
509
|
// class-token one, which is bound to the default dataSource.
|
|
513
|
-
new
|
|
510
|
+
new OutboxRetryScheduler(new FailedEventPublications(repo), cfg),
|
|
514
511
|
inject: [repositoryToken, retryConfigToken],
|
|
515
512
|
},
|
|
516
513
|
{ provide: cleanupConfigToken, useValue: cleanupCfg },
|
|
517
514
|
{
|
|
518
515
|
provide: cleanupToken,
|
|
519
|
-
useFactory: (repo, cfg) => new
|
|
516
|
+
useFactory: (repo, cfg) => new OutboxCleanupScheduler(repo, cfg),
|
|
520
517
|
inject: [repositoryToken, cleanupConfigToken],
|
|
521
518
|
},
|
|
522
519
|
{ provide: recoveryOptionsToken, useValue: recoveryOpts },
|
|
@@ -528,24 +525,24 @@ function buildPerDataSourceProviders(ds, repository, serializer, processorOpts,
|
|
|
528
525
|
// need a per-DS StartupRecoveryService class; deferred to a later
|
|
529
526
|
// phase when multi-DS recovery is exercised. Today's behaviour:
|
|
530
527
|
// recovery runs on the default-DS only.
|
|
531
|
-
{ provide: recoveryToken, useExisting:
|
|
528
|
+
{ provide: recoveryToken, useExisting: StartupRecoveryService },
|
|
532
529
|
{
|
|
533
530
|
provide: publisherToken,
|
|
534
|
-
useFactory: (publicationRegistry, listenerRegistry) => new
|
|
531
|
+
useFactory: (publicationRegistry, listenerRegistry) => new DataSourceOutboxPublisher(ds, publicationRegistry, listenerRegistry),
|
|
535
532
|
inject: [publicationRegistryToken, listenerRegistryToken],
|
|
536
533
|
},
|
|
537
534
|
];
|
|
538
535
|
}
|
|
539
536
|
function perDataSourceExports(ds) {
|
|
540
537
|
return [
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
538
|
+
getEventTypeRegistryToken(ds),
|
|
539
|
+
getEventPublicationRepositoryToken(ds),
|
|
540
|
+
getOutboxEventSerializerToken(ds),
|
|
541
|
+
getOutboxListenerRegistryToken(ds),
|
|
542
|
+
getEventPublicationRegistryToken(ds),
|
|
543
|
+
getExternalizationRegistryToken(ds),
|
|
544
|
+
getEventPublicationProcessorToken(ds),
|
|
545
|
+
getOutboxPublisherToken(ds),
|
|
549
546
|
];
|
|
550
547
|
}
|
|
551
548
|
/**
|
|
@@ -559,39 +556,39 @@ function perDataSourceExports(ds) {
|
|
|
559
556
|
function buildDefaultDataSourceAliases() {
|
|
560
557
|
const ds = DEFAULT_DATA_SOURCE;
|
|
561
558
|
return [
|
|
562
|
-
{ provide:
|
|
563
|
-
{ provide:
|
|
564
|
-
{ provide:
|
|
565
|
-
{ provide:
|
|
566
|
-
{ provide:
|
|
567
|
-
{ provide:
|
|
568
|
-
{ provide:
|
|
569
|
-
{ provide:
|
|
570
|
-
{ provide:
|
|
571
|
-
{ provide:
|
|
572
|
-
{ provide:
|
|
573
|
-
{ provide:
|
|
574
|
-
{ provide:
|
|
575
|
-
{ provide:
|
|
576
|
-
{ provide:
|
|
559
|
+
{ provide: EVENT_TYPE_REGISTRY, useExisting: getEventTypeRegistryToken(ds) },
|
|
560
|
+
{ provide: EventTypeRegistry, useExisting: getEventTypeRegistryToken(ds) },
|
|
561
|
+
{ provide: EVENT_SERIALIZER, useExisting: getOutboxEventSerializerToken(ds) },
|
|
562
|
+
{ provide: EVENT_PUBLICATION_REPOSITORY, useExisting: getEventPublicationRepositoryToken(ds) },
|
|
563
|
+
{ provide: OutboxListenerRegistry, useExisting: getOutboxListenerRegistryToken(ds) },
|
|
564
|
+
{ provide: EventPublicationRegistry, useExisting: getEventPublicationRegistryToken(ds) },
|
|
565
|
+
{ provide: ExternalizationRegistry, useExisting: getExternalizationRegistryToken(ds) },
|
|
566
|
+
{ provide: EventPublicationProcessor, useExisting: getEventPublicationProcessorToken(ds) },
|
|
567
|
+
{ provide: StalenessMonitor, useExisting: perDsStalenessMonitorToken(ds) },
|
|
568
|
+
{ provide: OutboxRetryScheduler, useExisting: perDsRetrySchedulerToken(ds) },
|
|
569
|
+
{ provide: OutboxCleanupScheduler, useExisting: perDsCleanupSchedulerToken(ds) },
|
|
570
|
+
{ provide: OUTBOX_PROCESSOR_OPTIONS, useExisting: perDsProcessorOptionsToken(ds) },
|
|
571
|
+
{ provide: OUTBOX_STALENESS_CONFIG, useExisting: perDsStalenessConfigToken(ds) },
|
|
572
|
+
{ provide: OUTBOX_RETRY_CONFIG, useExisting: perDsRetryConfigToken(ds) },
|
|
573
|
+
{ provide: OUTBOX_RECOVERY_OPTIONS, useExisting: perDsRecoveryOptionsToken(ds) },
|
|
577
574
|
];
|
|
578
575
|
}
|
|
579
576
|
function defaultDataSourceAliasTokens() {
|
|
580
577
|
return [
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
578
|
+
EVENT_TYPE_REGISTRY,
|
|
579
|
+
EventTypeRegistry,
|
|
580
|
+
EVENT_SERIALIZER,
|
|
581
|
+
EVENT_PUBLICATION_REPOSITORY,
|
|
582
|
+
OutboxListenerRegistry,
|
|
583
|
+
EventPublicationRegistry,
|
|
584
|
+
ExternalizationRegistry,
|
|
585
|
+
EventPublicationProcessor,
|
|
586
|
+
StalenessMonitor,
|
|
587
|
+
OutboxRetryScheduler,
|
|
588
|
+
OUTBOX_PROCESSOR_OPTIONS,
|
|
589
|
+
OUTBOX_STALENESS_CONFIG,
|
|
590
|
+
OUTBOX_RETRY_CONFIG,
|
|
591
|
+
OUTBOX_RECOVERY_OPTIONS,
|
|
595
592
|
];
|
|
596
593
|
}
|
|
597
594
|
/**
|
|
@@ -605,9 +602,9 @@ function defaultDataSourceAliasTokens() {
|
|
|
605
602
|
*/
|
|
606
603
|
function buildFacadePublisherProvider(moduleClass) {
|
|
607
604
|
return [
|
|
608
|
-
|
|
605
|
+
OutboxEventPublisher,
|
|
609
606
|
{
|
|
610
|
-
provide:
|
|
607
|
+
provide: OUTBOX_DATA_SOURCE_NAMES,
|
|
611
608
|
useValue: privateRegistrations(moduleClass),
|
|
612
609
|
},
|
|
613
610
|
];
|
|
@@ -629,10 +626,10 @@ function buildFacadePublisherProvider(moduleClass) {
|
|
|
629
626
|
*/
|
|
630
627
|
function buildMultiDsRegistrarProviders() {
|
|
631
628
|
return [
|
|
632
|
-
|
|
629
|
+
MultiDsOutboxListenerRegistrar,
|
|
633
630
|
{
|
|
634
|
-
provide:
|
|
635
|
-
useExisting:
|
|
631
|
+
provide: OUTBOX_LISTENER_REGISTRAR_TOKEN,
|
|
632
|
+
useExisting: MultiDsOutboxListenerRegistrar,
|
|
636
633
|
},
|
|
637
634
|
];
|
|
638
635
|
}
|
|
@@ -645,7 +642,7 @@ function buildMultiDsRegistrarProviders() {
|
|
|
645
642
|
*/
|
|
646
643
|
function buildProcessingBundleProvider(moduleClass) {
|
|
647
644
|
return {
|
|
648
|
-
provide:
|
|
645
|
+
provide: OUTBOX_PROCESSING_BUNDLE,
|
|
649
646
|
useFactory: (moduleRef) => {
|
|
650
647
|
const dsNames = Array.from(privateRegistrations(moduleClass).keys());
|
|
651
648
|
// Resolve lazily by capturing dsNames + moduleRef in closure. The
|
|
@@ -655,7 +652,7 @@ function buildProcessingBundleProvider(moduleClass) {
|
|
|
655
652
|
const get = (token) => moduleRef.get(token, { strict: false });
|
|
656
653
|
return {
|
|
657
654
|
get processors() {
|
|
658
|
-
return dsNames.map((ds) => get(
|
|
655
|
+
return dsNames.map((ds) => get(getEventPublicationProcessorToken(ds)));
|
|
659
656
|
},
|
|
660
657
|
get monitors() {
|
|
661
658
|
return dsNames.map((ds) => get(perDsStalenessMonitorToken(ds)));
|
|
@@ -671,7 +668,7 @@ function buildProcessingBundleProvider(moduleClass) {
|
|
|
671
668
|
},
|
|
672
669
|
};
|
|
673
670
|
},
|
|
674
|
-
inject: [
|
|
671
|
+
inject: [ModuleRef],
|
|
675
672
|
};
|
|
676
673
|
}
|
|
677
674
|
/**
|
|
@@ -691,5 +688,5 @@ function privateRegistrations(moduleClass) {
|
|
|
691
688
|
// no longer used directly in this file (the per-DS
|
|
692
689
|
// publisher pushes hooks directly onto the active-transaction object,
|
|
693
690
|
// bypassing manager.registerBeforeCommit's single-tx assumption).
|
|
694
|
-
const _txManagerRef =
|
|
691
|
+
const _txManagerRef = TransactionManager;
|
|
695
692
|
//# sourceMappingURL=outbox.module.js.map
|