import type { Constructor } from '@cratis/fundamentals'; import type { EventContext } from '../../events/EventContext.js'; import type { EventAndContext } from './EventAndContext.js'; import type { BatchOutcome } from './BatchOutcome.js'; /** * The events a batch method is called with, in sequence order, and the way it reports partitions it could not handle. * * Returning normally means every partition in the batch succeeded. Throwing fails every partition in the batch at its * first event in the batch. {@link EventBatch.fail} and {@link EventBatch.defer} report a single partition, so the rest * of the batch can still succeed. */ export declare class EventBatch implements Iterable { #private; /** * Creates a new {@link EventBatch}. * @param events - The events, in sequence order. * @param canDefer - Whether the kernel accepts deferred partitions. */ constructor(events: readonly EventAndContext[], canDefer?: boolean); /** The events in the batch, in sequence order. */ get events(): readonly EventAndContext[]; /** The number of events in the batch. */ get length(): number; /** The partitions (event source identifiers) the batch holds events for, in the order their first event appears. */ get partitions(): readonly string[]; /** The outcomes reported for single partitions, in the order they were reported. */ get outcomes(): readonly BatchOutcome[]; /** * Gets the events of one event type, narrowed to it. * @param eventType - The event constructor. * @returns The events of that type, in sequence order. */ ofType(eventType: Constructor): EventAndContext[]; /** * Fails a partition. Given a partition, it fails from its first event in the batch; given the context of an event, * it fails from that event, and the partition's earlier events count as handled. * @param partitionOrEvent - The partition (event source identifier), or the {@link EventContext} of the event it fails at. * @param error - What went wrong. Defaults to a {@link PartitionFailedInBatch} error. */ fail(partitionOrEvent: string | EventContext, error?: unknown): void; /** * Defers a partition: it is not failed, does not count towards quarantine, and is delivered again after a delay. * Given a partition, it is delivered again from its first event in the batch; given the context of an event, from that event. * When the kernel does not accept deferrals, the partition is failed with {@link DeferralNotSupportedByKernel} instead. * @param partitionOrEvent - The partition (event source identifier), or the {@link EventContext} of the event to deliver again from. * @param retryAfterMilliseconds - How long to wait, in milliseconds, before the partition is delivered again. */ defer(partitionOrEvent: string | EventContext, retryAfterMilliseconds: number): void; /** @inheritdoc */ [Symbol.iterator](): Iterator; } //# sourceMappingURL=EventBatch.d.ts.map