-
Notifications
You must be signed in to change notification settings - Fork 16
Queue API
Returns: A new job Queue JavaScript object.
The Queue(options, dbConfig) function can be called multiple times to create multiple job queues connected to multiple instances of RethinkDB.
The options and dbConfig parameters are optional. See the table below.
Both the options and dbConfig are passed to the Queue(options, dbConfig) function as JavaScript objects.
If the dbName database does not exist, it will be created.
| Key | Description | Defaults |
|---|---|---|
queueName |
Name of the queue | rjqJobQueue |
stallInterval |
Maximum working time in seconds before the job is considered stalled | 30 |
| Key | Description | Defaults |
|---|---|---|
host |
Name or IP address of the RethinkDB server | localhost |
port |
TCP port number for the RethinkDB server instance | 28015 |
db |
The name of the database to hold the job queues | rjqJobQueue |
Example using defaults:
const jobQueue = require('rethinkdb-job-queue')
// Connects to the local instance of RethinkDB with the following defaults.
// Database host: localhost
// Database port: 28015
// Database name: rjqJobQueue
// Queue Name: rjqJobQueue
const queue = jobQueue()
// Now use the 'queue' object to create jobs.Example using dbName and queueName:
// Connects to the local instance of RethinkDB.
const dbConfig = {
db: 'AppMail'
}
const options = {
queueName: 'NewsLetterJobs'
}
const newsLetterQueue = jobQueue(options, dbConfig)
// Now use the 'newsLetterQueue' object to create jobs.Example connecting to a remote RethinkDB instance:
// Connects to a remote instance of RethinkDB.
const dbConfig = {
host: '192.168.1.5',
port: '4000',
db: 'AppProd'
}
const options = {
queueName: 'ProcessJobs'
}
const processJobsQueue = jobQueue(options, dbConfig)
// Now use the 'processJobsQueue' object to create jobs.Returns: Promise resolving to a Queue object.
Once you have a queue factory returned from the connect(options) function, you can call create(queueName) to create the job queue.
The options are passed to the create() function as a JavaScript object. None of the options are required.
A table inside the connected database will be created for each queue based on the queueName option.
| Key | Description | Defaults |
|---|---|---|
queueName |
Name (or reason) of the queue | JobQueue |
stallInterval |
Maximum working time in seconds before the job is concidered stalled | 30 |
const jobQueue = require('rethinkdb-job-queue')
const localQFactory = jobQueue.connect()
const emailJobQOptions = {
queueName: 'EmailJobQueje'
}
var emailJobQueue = {}
localQFactory.create(emailJobQueue).then((newQueue) => {
// Use the new job queue to start queuing jobs.
emailJobQueue = newQueue
}).catch(console.error)TODO: add notes about err.cancelJob and err.cancelReason (maybe under queue.process)
- 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