/** * Generic worker-pool drain over a batched fetch source. The pipeline * owns mechanism: concurrent workers, low-watermark refill, * batch-completion detection, deferred-release accumulation, and * end-of-drain cleanup. Plugin-specific policy (signal interpretation, * error swallowing, locator resolution) lives in the caller's hooks. */ export type ItemAction = "ack" | "release" | "ignore"; export interface ProcessItemResult { /** Pushed onto the drain's results array. */ value: TValue; /** What the pipeline does with the item: ack, release, or ignore (lease timeout returns it). */ action: ItemAction; /** Stop the drain after current in-flight items finish. */ abort?: boolean; } export interface BatchedDrainPipelineOptions { concurrency: number; maxItems?: number; leaseSize: number; /** * Fetch the next batch. `"exhausted"` signals no more items will arrive. * Errors thrown after the initial fetch surface only after in-flight * workers wind down. */ fetchBatch(requestedSize: number): Promise<{ id: string; items: TItem[]; } | "exhausted">; /** * Run the per-item callback. The returned `action` controls * ack/release; `abort: true` short-circuits the drain after current * in-flight items finish. */ processItem(item: TItem): Promise>; /** * Called once per item the callback marked `"ack"`, immediately after * processItem returns. Per-item rather than per-batch so a crash * mid-drain can't roll back already-committed items. The hook is on * the hot path; in drainTriggerInbox it issues one * sdk.ackTriggerInboxMessages call per acked message. */ ackItem(batchId: string, itemId: string): Promise; /** * Called once at drain end per batch with items the callback marked * `"release"`. Stays batched (vs ackItem's per-item) because an * unreleased item just waits for the lease timeout — no work is lost. */ releaseItems(batchId: string, itemIds: string[]): Promise; } export declare function runBatchedDrainPipeline(options: BatchedDrainPipelineOptions): Promise; //# sourceMappingURL=pipeline.d.ts.map