-
Notifications
You must be signed in to change notification settings - Fork 16
Queue.getJob
Grant Carthew edited this page Oct 1, 2016
·
7 revisions
Parameter: JobOrId
Object or String or Array
- A single Job or Id, or an array of Jobs or Ids.
Returns: Promise
=> Array
- An array of one or more Job objects.
Example:
q.getJob(jobs).then((savedJobs) => {
// savedJobs is an array of one or more Jobs
}).catch(err => console.error(err))
At any time and for any reason you may want to retrieve the details of a job in the queue. This is the API for you.
Simply call Queue.getJob
passing in a single or array of jobs or job ids.
It is important to note that the returned Promise resolves to an array of jobs even if you only supplied a single job or id.
This example shows how to get the details for one job.
const Queue = require('rethinkdb-job-queue')
const q = new Queue()
const job = q.createJob()
// Decorate your job with job data for processing here
q.addJob(job).then((savedJobs) => {
// savedJobs is an array of a single job object
return q.getJob(savedJobs)
}).then((retrievedJobs) => {
// Use the retrievedJobs array to get what you need.
console.dir(retrievedJobs[0].log)
}).catch(err => console.error(err))
This example shows how to get the details for more than one job.
const Queue = require('rethinkdb-job-queue')
const q = new Queue()
const jobs = [q.createJob(), q.createJob()]
// The jobs array will contain 2 jobs
// Don't forget to decorate your jobs with job data
q.addJob(jobs).then((savedJobs) => {
// savedJobs is an array of a 2 job objects
return q.getJob(savedJobs)
}).then((retrievedJobs) => {
// Use the retrievedJobs array to get what you need.
retrievedJobs.map((singleJob) => {
console.dir(singleJob.log)
})
}).catch(err => console.error(err))
- 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