Skip to content

Queue.jobOptions

Grant Carthew edited this page Oct 1, 2016 · 8 revisions

Property Details

Usage: Read / Write

Set: Object

  • A valid Job Options object to change the job default options for the Queue object.

Get: Object

  • The currently configured default job options for the Queue object.

Example:

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

let originalOptions = q.jobOptions
// originalOptions will be as follows
// { priority: 'normal', timeout: 300000, retryMax: 3, retryDelay: 600000 }

q.jobOptions = { timeout: 400000 }
let newOptions = q.jobOptions

// newOptions will be as follows
// { priority: 'normal', timeout: 400000, retryMax: 3, retryDelay: 600000 }

Description

The Queue object jobOptions property is used to define the default options for new jobs created with Queue.createJob. You do not need to change the default job options using this property. Only use it if you are not happy with the builtin defaults.

See the Job Options document for a description of the available job options and their default values.

Example

This example creates two jobs called job1 and job2 after changing the jobOptions property. After creating the jobs, job1 will have the new default options while job2 will have a different timeout value.

const Queue = require('rethinkdb-job-queue')
const q = new Queue()
const options = {
  priority: 'low',
  timeout: 200000,
  retryMax: 2,
  retryDelay: 0
}

let originalOptions = q.jobOptions
// originalOptions will be as follows
// { priority: 'normal', timeout: 300000, retryMax: 3, retryDelay: 600000 }

// Setting the new job default options
q.jobOptions = options

let job1 = q.createJob()
// This job1 object will have the new default options above

let job2 = q.createJob({ timeout: 400000 })
// This job2 object will have the new defaults except for the timeout value of 400000

// Now add the jobs to the Queue
q.addJob([job1, job2]).catch(err => console.error(err))

Main

How It Works

Contributing

API

Queue Methods

Queue Properties

Queue Events

Job Methods

Job Properties

Documentation

Clone this wiki locally