The CronyxClient
class is responsible for managing the lifecycle of jobs, initiating, and executing tasks based on given criteria.
constructor(options: CronyxClientOptions)
Parameters:
options
:
Initiate the job based on the specified criteria.
requestJobStart(options: JobStartOptions): Promise<Job>
Parameters:
options
:jobName
: string - A unique identifier for the series of jobs.jobInterval
: Duration | string | number - Specifies how frequently the job runs.startBuffer?
(optional): Duration | number - Adds a delay before the job starts.retryInterval?
(optional): Duration | number - Allows bypassing of an active job lock after a specified period.requiredJobNames?
(optional): Array<string> - Specifies dependencies using their job names.timezone?
(optional): string - Overridestimezone
of the constructor argument.noLock?
(optional): boolean - Bypasses job locks, letting other processes run the job.jobIntervalStartedAt?
(optional): Date - Sets the start interval manually. Use with thenoLock
option.
Execute a specified task for a job, often used when a specific task needs to be run without considering the full job lifecycle.
requestJobExec(options: JobStartOptions, task: (job: Job) => Promise<void>): Promise<Job>
Parameters:
options
: Same as described inrequestJobStart
.task
: Function that defines the task to be executed for the job.
The Job
class encapsulates individual tasks managed and executed by Cronyx.
id
: string | null - A unique identifier for the job, returnsnull
for bypassed job lock.name
: string - The identifier for the series of jobs.interval
: number - The frequency of the job in milliseconds.isActive
: boolean - The active status of the job.intervalStartedAt
: Date - Starting time of the job's interval.intervalEndedAt
: Date - Ending time of the job's interval.createdAt
: Date - Created date of the job.updatedAt
: Date - Last updated date of the job.
Mark a job as successfully completed.
finish(): Promise<void>
Indicate that a job has been prematurely halted, either due to an error or another unforeseen circumstance.
interrupt(): Promise<void>