import { WorkerOptions } from 'bullmq';

/**
 * Standard worker options for stall detection and recovery.
 * Defined in ADR-053.
 *
 * Note: This is a partial configuration that must be spread into a full
 * WorkerOptions object along with a `connection` property when creating workers.
 */
export const defaultWorkerOptions: Omit<WorkerOptions, 'connection'> = {
  // Check for stalled jobs every 30 seconds
  stalledInterval: 30000,
  // Fail job after 3 stalls (prevents infinite loops causing infinite retries)
  maxStalledCount: 3,
  // Duration of the lock for the job in milliseconds.
  // If the worker doesn't renew this (e.g. crash), the job stalls.
  lockDuration: 30000,
};
