import { JobEntity } from './job.entity'; type JobHandlerResult = { success: boolean; data: T; }; type JobHandler = (job: JobEntity) => JobHandlerResult | Promise>; type TimeoutJobParams = OriginalJobParams & { /** * Id of original timed out job */ originalJobId: string; }; /** * Handler that will be called once job is considered timed out, * e.g. after being stuck in running for too long. * This handler also returns a `JobHandlerResult` because * it will be called as part of an internally scheduled timeout job. * * NOTE that the result of this handler will be stored in * the internally scheduled timeout job, NOT the original job. * This timeout handler will be called with the above mentioned internally scheduled timeout job * which will reference the original timed out job in its `params.originalJobId` */ type JobTimeoutHandler = (job: JobEntity) => JobHandlerResult | Promise>; type JobStatus = 'scheduled' | 'running' | 'successful' | 'failed' | 'timed-out'; export { JobHandler, JobHandlerResult, JobStatus, JobTimeoutHandler, TimeoutJobParams, };