//#region src/pipeline.d.ts interface DrainPipelineOptions { batch?: { /** Maximum number of events per batch sent to the drain function. @default 50 */size?: number; /** Maximum time (ms) an event can stay buffered before a flush is triggered, even if the batch is not full. @default 5000 */ intervalMs?: number; }; retry?: { /** Total number of attempts (including the initial one) before dropping the batch. @default 3 */maxAttempts?: number; /** Delay strategy between retry attempts. @default 'exponential' */ backoff?: 'exponential' | 'linear' | 'fixed'; /** Base delay (ms) for the first retry. Scaled by the backoff strategy on subsequent retries. @default 1000 */ initialDelayMs?: number; /** Upper bound (ms) for any single retry delay. @default 30000 */ maxDelayMs?: number; }; /** Maximum number of events held in the buffer. When exceeded, the oldest event is dropped. @default 1000 */ maxBufferSize?: number; /** Called when a batch is dropped after all retry attempts are exhausted, or when the buffer overflows. */ onDropped?: (events: T[], error?: Error) => void; } interface PipelineDrainFn { (ctx: T): void; /** Flush all buffered events. Call on server shutdown. */ flush: () => Promise; readonly pending: number; } /** * Create a drain pipeline that batches events, retries on failure, and manages buffer overflow. * * Returns a higher-order function: pass your drain adapter to get a hook-compatible function. * * @example * ```ts * const pipeline = createDrainPipeline({ batch: { size: 50 } }) * const drain = pipeline(async (batch) => { * await sendToBackend(batch) * }) * * // Use as a hook * nitroApp.hooks.hook('mxllog:drain', drain) * * // Flush on shutdown * nitroApp.hooks.hook('close', () => drain.flush()) * ``` */ declare function createDrainPipeline(options?: DrainPipelineOptions): (drain: (batch: T[]) => void | Promise) => PipelineDrainFn; //#endregion export { DrainPipelineOptions, PipelineDrainFn, createDrainPipeline }; //# sourceMappingURL=pipeline.d.mts.map