import { JobModel } from './models/index'; import { TaskCallback, JobContext, JobScheduler, PublishableTask } from './index'; import { Properties } from './types'; export declare const isHealthy: (heartbeat: number, timeout: number) => boolean; export declare const computeNextRuns: (interval: string, { timezone, startDate, count, }?: { timezone?: string | undefined; startDate?: string | undefined; count?: number | undefined; }) => string[]; export declare const computeNextRun: (interval: string, { timezone, startDate, }?: { timezone?: string | undefined; startDate?: string | undefined; }) => string; /** * @description Call publish method on Publishable Tasks passing JobContext * @param task {SteveoTask} * @returns */ export declare const taskRunner: (task: PublishableTask) => (payload: Properties, context?: JobContext) => Promise; export type TimestampHelper = (job: JobModel, task: TaskCallback) => (args: T, context: JobContext) => Promise; /** * @description This helper function is used to manipulate the timestamps on the job row in the DB * It does the following: * 1. Adds an accepted at timestamp (as the current timestamp) on the job to signal the job was accepted at this time * 2. Runs the callback (whatever the task is) * 3. When the callback runs successfully without any issues, it calculates the next run at for the job using its lunartick (https://www.npmjs.com/package/lunartick) rule and adds the following to the job * - queued: false //signalling the job is now over and ready to be picked up at the next run time * - nextRunAt: timestamp //time to pick up the job * - lastFinishedAt: timestamp //when did the job finish * 4. If the callback fails for some reason, it adds a failure to the job and reruns it with a backoff * @returns Promise */ export declare const timestampHelperFactory: (jobScheduler: JobScheduler) => TimestampHelper;