@dugongjs/core
Version:
37 lines (36 loc) • 2.24 kB
TypeScript
import type { IDomainEventRepository, IMessageConsumer } from "../../ports/index.js";
import type { IConsumedMessageRepository } from "../../ports/outbound/repository/i-consumed-message-repository.js";
import { AbstractAggregateHandler, type AbstractAggregateHandlerOptions } from "../abstract-aggregate-handler/abstract-aggregate-handler.js";
export type WaitForMessageConsumerOptions = Omit<AbstractAggregateHandlerOptions<any> & {
domainEventRepository: IDomainEventRepository;
consumedMessageRepository: IConsumedMessageRepository;
messageConsumer: IMessageConsumer<any>;
pollingInterval?: number;
}, "transactionManager">;
/**
* Utility class to wait for a message to be consumed. This is primarily intended for testing purposes.
*/
export declare class WaitForMessageConsumer extends AbstractAggregateHandler<any> {
private readonly domainEventRepository;
private readonly consumedMessageRepository;
private readonly messageConsumer;
private readonly pollingInterval;
constructor(options: WaitForMessageConsumerOptions);
/**
* Waits for the specified messages to be consumed by the given message consumer.
* @param consumerName Name of the message consumer.
* @param ids IDs of the messages to wait for.
* @returns A promise that resolves when all messages are consumed.
*/
waitForMessagesToBeConsumed(consumerName: string, ...ids: string[]): Promise<void>;
/**
* Waits for all domain events of a specific aggregate to be consumed by the specified consumer.
* This method retrieves the domain events for the specified aggregate and waits for them to be consumed by the given consumer.
* @param consumerName Name of the message consumer.
* @param aggregateId ID of the aggregate whose domain events are to be consumed.
* @param tenantId Optional tenant ID to scope the domain events.
* @param fromSequenceNumber Optional sequence number to start from when retrieving domain events.
* @returns A promise that resolves when all domain events are consumed.
*/
waitForAggregateDomainEventsToBeConsumed(consumerName: string, aggregateId: string, tenantId?: string | null, fromSequenceNumber?: number): Promise<void>;
}