Skip to content

Job API

Grant Carthew edited this page Jul 1, 2016 · 22 revisions

Description

Job objects are created by calling queue.createJob() passing data and options. The jobs will not be saved into the queue database until you call queue.addJob() passing in the job object.

Job objects can also be accessed during execution of the queue.process() callback function, and by calling queue.getJob() passing the id of the job.

The methods below can be used to interact with the job objects.

cleanCopy getter

Returns:_ A JavaScript Object populated with the properties of the job.

This method is mostly used within the rethinkdb-job-queue to save the jobs to the database. You can use this method if you want a copy of the job properties.

The returned job object has all methods and the reference to the owning Queue removed leaving only the jobs properties. The job.priority value will be converted to a string rather than the integer saved in the database.

const Queue = require('rethinkdb-job-queue')
const queue = new Queue(options)

const job = queue.createJob({ job:data })
const cleanCopy = job.cleanCopy

createLog

Type: Method

Returns: Object

Parameters: string message.

Use createLog to get a basic schema populated with the jobs main properties. The returned log object will not be saved into the database until job.addLog() is called passing in the log object.

Once you have the log object, populate it with any values you would like to record for future reference prior to calling job.addLog().

addLog

Type: Method

Returns: Promise

Parameters: Object

After calling job.createLog() and getting a log object, save it against the job in the database using job.addLog(log).

Main

How It Works

Contributing

API

Queue Methods

Queue Properties

Queue Events

Job Methods

Job Properties

Documentation

Clone this wiki locally