Job

Job

new Job(args)

Parameters:
Name Type Description
args Object
Properties:
Name Type Description
agenda Object

The Agenda instance

attrs Object
Source:

Methods

computeNextRunAt() → {exports}

Internal method used to compute next time a job should run and sets the proper values

Source:

disable() → {exports}

Prevents the job type from running

Source:

enable() → {Job}

Allows job type to run

Source:

fail(reason) → {exports}

Fails the job with a reason (error) specified

Parameters:
Name Type Description
reason Error | String

reason job failed

Source:

isRunning() → {Boolean}

A job is running if: (lastRunAt exists AND lastFinishedAt does not exist) OR (lastRunAt exists AND lastFinishedAt exists but the lastRunAt is newer [in time] than lastFinishedAt)

Source:

priority(priority) → {Number}

Internal method to turn priority into a number

Parameters:
Name Type Description
priority String | Number

string to parse into number

Source:

remove() → {Promise}

Remove the job from MongoDB

Source:

repeatAt(time) → {exports}

Sets a job to repeat at a specific time

Parameters:
Name Type Description
time String

time to repeat job at (human readable or number)

Source:

repeatEvery(interval, options) → {Job}

Sets a job to repeat every X amount of time

Parameters:
Name Type Description
interval String

repeat every X

options Object

options to use for job

Source:

run() → {Promise}

Internal method (RUN)

Source:

schedule(time) → {exports}

Schedules a job to run at specified time

Parameters:
Name Type Description
time String

schedule a job to run "then"

Source:

toJSON() → {Object}

Given a job, turn it into an object we can store in Mongo

Source:

touch(cb) → {undefined}

Updates "lockedAt" time so the job does not get picked up again

Parameters:
Name Type Description
cb function

called when job "touch" fails or passes

Source:

unique(unique, opts) → {exports}

Data to ensure is unique for job to be created

Parameters:
Name Type Description
unique Object

mongo data query for unique

opts Object

unique options

Source: