/** * Platform-neutral persistence and lifecycle contract used by the background-jobs * runtime. Adapters own durable queue state; transport and job execution remain * separate concerns. */ export default class BackgroundJobsAdapter { /** * Declares exact durable fencing support for release-scoped generations. * Third-party adapters must override this only after implementing the full * snapshot, owner, report, and recovery contract. * @returns {boolean} - Whether generation mode is supported. */ supportsReleaseScopedGenerations(): boolean; /** * Declares atomic producer-handoff validation plus enqueue support. A * generation-capable adapter must override this together with * `enqueueFromOwnedHandoff`. * @returns {boolean} - Whether atomic owned enqueue is supported. */ supportsOwnedEnqueueFromHandoff(): boolean; /** * Ensures the adapter can accept work. * @returns {Promise} - Resolves when ready. */ ensureReady(): Promise; /** * Closes adapter-owned resources. * @returns {Promise} - Resolves after close. */ close(): Promise; /** * Reports adapter health. * @returns {Promise} - Adapter health. */ health(): Promise; /** * Ensures framework-owned persistence during a migration lifecycle. Non-SQL * adapters may leave this as a no-op. * @param {{dbs: Record}} _args - Migrated databases. * @returns {Promise} - Resolves when complete. */ ensureFrameworkSchema(_args: { dbs: Record; }): Promise; /** * Reconciles configured queue limits. * @returns {Promise} - Resolves after reconciliation. */ reconcileQueueConcurrency(): Promise; /** * Repairs drift in adapter-owned durable active concurrency counts. Adapters * without duplicate active-count persistence can keep this no-op result. * @returns {Promise} - Repair summary. */ reconcileActiveConcurrency(): Promise; /** * Enqueues a job. * @param {{jobName: string, args: Array>, options?: import("./types.js").BackgroundJobOptions}} _args - Job request. * @returns {Promise} - Job id. */ enqueue(_args: { jobName: string; args: Array>; options?: import("./types.js").BackgroundJobOptions; }): Promise; /** * Atomically validates an exact producing handoff and enqueues its follow-up. * @param {{jobName: string, args: Array>, options?: import("./types.js").BackgroundJobOptions, producerInvocationId?: string, producerProof: import("./types.js").BackgroundJobProducerProof}} _args - Owned enqueue request. * @returns {Promise} - Job id. */ enqueueFromOwnedHandoff(_args: { jobName: string; args: Array>; options?: import("./types.js").BackgroundJobOptions; producerInvocationId?: string; producerProof: import("./types.js").BackgroundJobProducerProof; }): Promise; /** * Replaces the owner of a stable schedule key. * @param {{scheduleKey: string, jobName: string, args: Array>, options?: import("./types.js").BackgroundJobOptions}} _args - Replacement request. * @returns {Promise} - Replacement result. */ replaceScheduled(_args: { scheduleKey: string; jobName: string; args: Array>; options?: import("./types.js").BackgroundJobOptions; }): Promise; /** * Cancels the owner of a stable schedule key. * @param {string} _scheduleKey - Stable schedule key. * @returns {Promise} - Cancellation result. */ cancelScheduled(_scheduleKey: string): Promise; /** * Reads current stable ownership and optional terminal history. * @param {string} _scheduleKey - Stable schedule key. * @param {{includeLatestTerminal?: boolean}} [_options] - Lookup options. * @returns {Promise} - Normalized public jobs. */ getScheduledJob(_scheduleKey: string, _options?: { includeLatestTerminal?: boolean; }): Promise; /** * Expedites a future queued stable owner without changing its identity. * @param {string} _scheduleKey - Stable schedule key. * @returns {Promise} - Wake result. */ wakeScheduled(_scheduleKey: string): Promise; /** * Finds the next eligible job. * @param {{executionMode?: import("./types.js").BackgroundJobExecutionMode | import("./types.js").BackgroundJobExecutionMode[]}} [_args] - Dequeue filters. * @returns {Promise} - Next eligible job. */ nextAvailableJob(_args?: { executionMode?: import("./types.js").BackgroundJobExecutionMode | import("./types.js").BackgroundJobExecutionMode[]; }): Promise; /** * Finds the soonest future job. * @returns {Promise} - Soonest future job. */ nextScheduledJob(): Promise; /** * Reads one job. * @param {string} _jobId - Job id. * @returns {Promise} - Job row. */ getJob(_jobId: string): Promise; /** * Starts a job by claiming its durable handoff. * When `handoffId` is supplied, the adapter must persist and return that exact * id so the caller can fence an ambiguous commit acknowledgement. * @param {import("./types.js").BackgroundJobHandoffRequest} _args - Handoff request. * @returns {Promise} - Claimed handoff. */ markHandedOff(_args: import("./types.js").BackgroundJobHandoffRequest): Promise; /** * Marks a handed-off job successful. * @param {{jobId: string, handoffId?: string, workerId?: string, handedOffAtMs?: number}} _args - Completion report. * @returns {Promise} - Whether the fenced report was accepted. */ markCompleted(_args: { jobId: string; handoffId?: string; workerId?: string; handedOffAtMs?: number; }): Promise; /** * Records pooled-child acceptance evidence (received/started timestamps plus * runner identity) for a handed-off job, fenced by its active handoff lease. * Only the fields supplied are written. * @param {{jobId: string, handoffId?: string, workerId?: string, handedOffAtMs?: number, receivedAtMs?: number, startedAtMs?: number, childInstanceId?: string, childPid?: number}} _args - Acceptance report. * @returns {Promise} - Whether the fenced report was accepted. */ markChildAccepted(_args: { jobId: string; handoffId?: string; workerId?: string; handedOffAtMs?: number; receivedAtMs?: number; startedAtMs?: number; childInstanceId?: string; childPid?: number; }): Promise; /** * Returns a handed-off job to its schedule. * @param {{jobId: string, delayMs: number, handoffId?: string, workerId?: string, handedOffAtMs?: number}} _args - Reschedule report. * @returns {Promise} - Whether the fenced report was accepted. */ markRescheduled(_args: { jobId: string; delayMs: number; handoffId?: string; workerId?: string; handedOffAtMs?: number; }): Promise; /** * Returns a handed-off job to the queue. * @param {{jobId: string, handoffId: string}} _args - Handoff release. * @returns {Promise} - Resolves after the job is returned. */ markReturnedToQueue(_args: { jobId: string; handoffId: string; }): Promise; /** * Finds active handoffs for a worker. * @param {{workerId: string}} _args - Worker identity. * @returns {Promise>} - Active worker handoffs. */ handedOffJobsForWorker(_args: { workerId: string; }): Promise>; /** * Snapshots exact active handoffs before a new main generation accepts worker * reconnects. Adapters that do not persist worker leases may return none. * @returns {Promise} - Exact active handoffs. */ snapshotHandedOffJobs(): Promise; /** * Applies orphan failure semantics to unchanged exact handoff snapshots. * Adapters that return startup snapshots must implement the matching fenced * transition. * @param {{handoffs: import("./types.js").BackgroundJobHandoffSnapshot[], error: ReturnType}} _args - Exact leases and orphan reason. * @returns {Promise} - Accepted transitions. */ markOrphanedHandoffs(_args: { handoffs: import("./types.js").BackgroundJobHandoffSnapshot[]; error: ReturnType; }): Promise; /** * Marks a handed-off job failed or retryable. * @param {{jobId: string, error: ReturnType, handoffId?: string, workerId?: string, handedOffAtMs?: number}} _args - Failure report. * @returns {Promise} - Updated job when accepted. */ markFailed(_args: { jobId: string; error: ReturnType; handoffId?: string; workerId?: string; handedOffAtMs?: number; }): Promise; /** * Reclaims expired handoffs. * @param {{orphanedAfterMs?: number}} [_args] - Sweep options. * @returns {Promise} - Newly orphaned jobs. */ markOrphanedJobs(_args?: { orphanedAfterMs?: number; }): Promise; /** * Prunes terminal jobs past their retention windows. * @param {{completedTtlMs?: number | null, failedTtlMs?: number | null, batchSize?: number}} [_args] - Retention options. * @returns {Promise} - Deleted rows. */ pruneTerminalJobs(_args?: { completedTtlMs?: number | null; failedTtlMs?: number | null; batchSize?: number; }): Promise; } //# sourceMappingURL=adapter.d.ts.map