/** * Dedicated error type thrown when a queued command is rejected because * its lane was cleared. Callers that fire-and-forget enqueued tasks can * catch (or ignore) this specific type to avoid unhandled-rejection noise. */ export declare class CommandLaneClearedError extends Error { constructor(lane?: string); } /** * Dedicated error type thrown when a new command is rejected because the * gateway is currently draining for restart. */ export declare class GatewayDrainingError extends Error { constructor(); } /** * Mark gateway as draining for restart so new enqueues fail fast with * `GatewayDrainingError` instead of being silently killed on shutdown. */ export declare function markGatewayDraining(): void; export declare function setCommandLaneConcurrency(lane: string, maxConcurrent: number): void; export declare function enqueueCommandInLane(lane: string, task: () => Promise, opts?: { warnAfterMs?: number; onWait?: (waitMs: number, queuedAhead: number) => void; }): Promise; export declare function enqueueCommand(task: () => Promise, opts?: { warnAfterMs?: number; onWait?: (waitMs: number, queuedAhead: number) => void; }): Promise; export declare function getQueueSize(lane?: string): number; export declare function getTotalQueueSize(): number; export declare function clearCommandLane(lane?: string): number; /** * Reset all lane runtime state to idle. Used after SIGUSR1 in-process * restarts where interrupted tasks' finally blocks may not run, leaving * stale active task IDs that permanently block new work from draining. * * Bumps lane generation and clears execution counters so stale completions * from old in-flight tasks are ignored. Queued entries are intentionally * preserved — they represent pending user work that should still execute * after restart. * * After resetting, drains any lanes that still have queued entries so * preserved work is pumped immediately rather than waiting for a future * `enqueueCommandInLane()` call (which may never come). */ export declare function resetAllLanes(): void; /** * Returns the total number of actively executing tasks across all lanes * (excludes queued-but-not-started entries). */ export declare function getActiveTaskCount(): number; /** * Wait for all currently active tasks across all lanes to finish. * Polls at a short interval; resolves when no tasks are active or * when `timeoutMs` elapses (whichever comes first). * * New tasks enqueued after this call are ignored — only tasks that are * already executing are waited on. */ export declare function waitForActiveTasks(timeoutMs: number): Promise<{ drained: boolean; }>;