@@ -17,12 +17,15 @@ export type OutboxDependencies<SupportedEvents extends CommonEventDefinition[]>
1717 eventEmitter : DomainEventEmitter < SupportedEvents >
1818}
1919
20- export type OutboxConfiguration = {
20+ export type OutboxProcessorConfiguration = {
2121 maxRetryCount : number
2222 emitBatchSize : number
23- jobIntervalInMs : number
2423}
2524
25+ export type OutboxConfiguration = {
26+ jobIntervalInMs : number
27+ } & OutboxProcessorConfiguration
28+
2629/**
2730 * Main logic for handling outbox entries.
2831 *
@@ -31,17 +34,16 @@ export type OutboxConfiguration = {
3134export class OutboxProcessor < SupportedEvents extends CommonEventDefinition [ ] > {
3235 constructor (
3336 private readonly outboxDependencies : OutboxDependencies < SupportedEvents > ,
34- private readonly maxRetryCount : number ,
35- private readonly emitBatchSize : number ,
37+ private readonly outboxProcessorConfiguration : OutboxProcessorConfiguration ,
3638 ) { }
3739
3840 public async processOutboxEntries ( context : JobExecutionContext ) {
3941 const { outboxStorage, eventEmitter, outboxAccumulator } = this . outboxDependencies
4042
41- const entries = await outboxStorage . getEntries ( this . maxRetryCount )
43+ const entries = await outboxStorage . getEntries ( this . outboxProcessorConfiguration . maxRetryCount )
4244
4345 await PromisePool . for ( entries )
44- . withConcurrency ( this . emitBatchSize )
46+ . withConcurrency ( this . outboxProcessorConfiguration . emitBatchSize )
4547 . process ( async ( entry ) => {
4648 try {
4749 await eventEmitter . emit ( entry . event , entry . data , entry . precedingMessageMetadata )
@@ -96,8 +98,7 @@ export class OutboxPeriodicJob<
9698
9799 this . outboxProcessor = new OutboxProcessor < SupportedEvents > (
98100 outboxDependencies ,
99- outboxConfiguration . maxRetryCount ,
100- outboxConfiguration . emitBatchSize ,
101+ outboxConfiguration ,
101102 )
102103 }
103104
0 commit comments