UNPKG

trigger.dev

Version:

A Command-Line Interface for Trigger.dev projects

57 lines (56 loc) 2.05 kB
import { RunLogger, SendDebugLogOptions } from "./logger.js"; import { TaskRunExecutionStatus, type RunExecutionData } from "@trigger.dev/core/v3"; import { MetadataClient } from "./overrides.js"; export type SnapshotState = { id: string; status: TaskRunExecutionStatus; }; type SnapshotHandler = (runData: RunExecutionData, deprecated: boolean) => Promise<void>; type SuspendableHandler = (suspendableSnapshot: SnapshotState) => Promise<void>; type SnapshotManagerOptions = { runFriendlyId: string; runnerId: string; initialSnapshotId: string; initialStatus: TaskRunExecutionStatus; logger: RunLogger; metadataClient?: MetadataClient; onSnapshotChange: SnapshotHandler; onSuspendable: SuspendableHandler; }; export declare class SnapshotManager { private runFriendlyId; private runnerId; private logger; private metadataClient?; private state; private isSuspendable; private readonly onSnapshotChange; private readonly onSuspendable; private changeQueue; private isProcessingQueue; private seenDeprecatedSnapshotIds; private readonly maxSeenDeprecatedSnapshotIds; constructor(opts: SnapshotManagerOptions); get snapshotId(): string; get status(): TaskRunExecutionStatus; get suspendable(): boolean; setSuspendable(suspendable: boolean): Promise<void>; /** * Update the snapshot ID and status without invoking any handlers * * @param snapshotId - The ID of the snapshot to update to * @param status - The status to update to */ updateSnapshot(snapshotId: string, status: TaskRunExecutionStatus): void; handleSnapshotChanges(snapshots: RunExecutionData[]): Promise<void>; get queueLength(): number; private statusCheck; private enqueueSnapshotChange; private processQueue; private applyChange; private hasBeenRestored; private checkSuspendableState; stop(): void; protected sendDebugLog(message: string, properties?: SendDebugLogOptions["properties"]): void; } export {};