-
Notifications
You must be signed in to change notification settings - Fork 16
Queue Constructor
The primary JavaScript object you use with rethinkdb-job-queue
is the Queue object. The Queue object connects to the RethinkDB database. If the database does not exist it will be created. Within the database there will be a table with the same name as the Queue name. Again, if the table does not exist it will be created.
The constructor for the Queue object takes two arguments being the Queue Connection object and the Queue Options object. The Connection and Queue options are not required and if not supplied the default values will apply.
See the Queue Connection and Queue Options documents for more detail about what the options are. This document is to show you how to create the Queue object with these options.
Constructor Options |
---|
Default Options |
Connection Options |
Connection Driver |
Queue Options |
Connection and Queue Options |
To use all the default options when creating the Queue object use the following instantiation code.
const Queue = require('rethinkdb-job-queue')
const q = new Queue()
See the Queue Connection and Queue Options documents for information about what the default values are.
To allow the Queue object to manage the RethinDB driver called rethinkdbdash simply pass the connection options to the Queue constructor as the first argument.
This example will connect to a RethinkDB instance running on host 'db01.domain.com' at port '12345'. If the database called 'JobQueue' does not exist it will create it.
const Queue = require('rethinkdb-job-queue')
const cxnOptions = {
host: 'db01.domain.com',
port: 12345,
db: 'JobQueue'
}
const q = new Queue(cxnOptions)
If you would prefer to manage the rethinkdbdash driver object yourself you can pass it as the first argument.
This example will connect to a RethinkDB instance running on host 'db01.domain.com' at the default port. It will create a database called 'JobQueue' if it does not exist.
const rethinkdbdash = require('rethinkdbdash')
const Queue = require('rethinkdb-job-queue')
const db01driver = rethinkdbdash({ host: 'db01.domain.com', db: 'JobQueue' })
const q = new Queue(db01driver)
If you are happy to connect to the default database name 'rjqJobQueue' on the 'localhost' at port 28015 but would like to change the Queue options, use the following instantiation code.
This example only changes the queue name
and changeFeed
options. It will create a table in the default database called 'RegistrationJobs' and disable global events.
const Queue = require('rethinkdb-job-queue')
const qOptions = {
name: 'RegistrationJobs',
changeFeed: false
}
const q = new Queue(null, qOptions)
By supplying a Queue Connection object and a Queue Options object you can control both the connection to RethinkDB and the operation of the queue. This is the most common way to create a Queue object.
This example will connect to a RethinkDB instance on host 'db01.domain.com' at port '12345' and database 'JobQueue'. The Queue object and table (or queue) name is set to 'RegistrationJobs' and the 'changeFeed' is disabled.
const Queue = require('rethinkdb-job-queue')
const cxnOptions = {
host: 'db01.domain.com',
port: 12345,
db: 'JobQueue'
}
const qOptions = {
name: 'RegistrationJobs',
changeFeed: false
}
const q = new Queue(cxnOptions, qOptions)
This example is the same as above however we are supplying a rethinkdbdash driver object rather than Connection options.
const rethinkdbdash = require('rethinkdbdash')
const Queue = require('rethinkdb-job-queue')
const db01driver = rethinkdbdash({ host: 'db01.domain.com', db: 'JobQueue' })
const qOptions = {
name: 'RegistrationJobs',
changeFeed: false
}
const q = new Queue(db01driver, qOptions)
- Introduction
- Tutorial
- Queue Constructor
- Queue Connection
- Queue Options
- Queue PubSub
- Queue Master
- Queue Events
- State Document
- Job Processing
- Job Options
- Job Status
- Job Retry
- Job Repeat
- Job Logging
- Job Editing
- Job Schema
- Job Name
- Complex Job
- Delayed Job
- Cancel Job
- Error Handling
- Queue.createJob
- Queue.addJob
- Queue.getJob
- Queue.findJob
- Queue.findJobByName
- Queue.containsJobByName
- Queue.cancelJob
- Queue.reanimateJob
- Queue.removeJob
- Queue.process
- Queue.review
- Queue.summary
- Queue.ready
- Queue.pause
- Queue.resume
- Queue.reset
- Queue.stop
- Queue.drop
- Queue.Job
- Queue.host
- Queue.port
- Queue.db
- Queue.name
- Queue.r
- Queue.id
- Queue.jobOptions [R/W]
- Queue.changeFeed
- Queue.master
- Queue.masterInterval
- Queue.removeFinishedJobs
- Queue.running
- Queue.concurrency [R/W]
- Queue.paused
- Queue.idle
- Event.ready
- Event.added
- Event.updated
- Event.active
- Event.processing
- Event.progress
- Event.log
- Event.pausing
- Event.paused
- Event.resumed
- Event.completed
- Event.cancelled
- Event.failed
- Event.terminated
- Event.reanimated
- Event.removed
- Event.idle
- Event.reset
- Event.error
- Event.reviewed
- Event.detached
- Event.stopping
- Event.stopped
- Event.dropped
- Job.setName
- Job.setPriority
- Job.setTimeout
- Job.setDateEnable
- Job.setRetryMax
- Job.setRetryDelay
- Job.setRepeat
- Job.setRepeatDelay
- Job.updateProgress
- Job.update
- Job.getCleanCopy
- Job.addLog
- Job.getLastLog