JobOptions
The JobOptions
interface defines the options for creating a new job in the queue.
Fields
jobType
: string — The type of the job.payload
: any — The payload for the job, type-safe per job type.maxAttempts?
: number — Maximum number of attempts for this job (default: 3).priority?
: number — Priority of the job (higher runs first, default: 0).runAt?
: Date | null — When to run the job (default: now).timeoutMs?
: number — Timeout for this job in milliseconds. If not set, uses the processor default or unlimited.
Example
const job = {
jobType: 'email',
payload: { to: 'user@example.com', subject: 'Hello' },
maxAttempts: 5,
priority: 10,
runAt: new Date(Date.now() + 60000), // run in 1 minute
timeoutMs: 30000, // 30 seconds
};