Optionalprocessor: string | URL | Processor<DataType, ResultType, NameType>Optionalopts: WorkerOptionsOptionalConnection: typeof RedisConnectionReadonlyidReadonlynameThe name of the queue.
ReadonlyoptsOptions for the queue.
ReadonlyqualifiedReturns a promise that resolves to a redis client. Normally used only by subclasses.
Returns the version of the Redis instance the client is connected to,
Cancels all jobs currently being processed by this worker. All active job processor functions will receive abort signals.
Optionalreason: stringOptional reason for the cancellation
Cancels a specific job currently being processed by this worker. The job's processor function will receive an abort signal.
The ID of the job to cancel
Optionalreason: stringOptional reason for the cancellation
true if the job was found and cancelled, false otherwise
Closes the worker and related redis connections.
This method waits for current jobs to finalize before returning.
Use force boolean parameter if you do not want to wait for current jobs to be processed. When using telemetry, be mindful that it can interfere with the proper closure of spans, potentially preventing them from being exported.
Promise that resolves when the worker has been closed.
This function is exposed only for testing purposes.
Optionalmilliseconds: numberOptionalabortController: AbortControllerForce disconnects a connection.
Emits an event. Normally used by subclasses to emit events.
The emitted event.
Public accessor method for LockManager to extend locks. This delegates to the protected scripts object.
Returns a promise that resolves to the next job in queue.
worker token to be assigned to retrieved job
a Job or undefined if no job was available in the queue.
Checks if worker is paused.
true if worker is paused, false otherwise.
Checks if worker is currently running.
true if worker is running, false otherwise.
Alias for emitter.removeListener().
Adds the listener function to the end of the listeners array for the
event named eventName. No checks are made to see if the listener has
already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple
times.
server.on('connection', (stream) => {
console.log('someone connected!');
});
Returns a reference to the EventEmitter, so that calls can be chained.
By default, event listeners are invoked in the order they are added. Theemitter.prependListener() method can be used as an alternative to add the
event listener to the beginning of the listeners array.
const myEE = new EventEmitter();
myEE.on('foo', () => console.log('a'));
myEE.prependListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// a
The callback function
Adds a one-timelistener function for the event named eventName. The
next time eventName is triggered, this listener is removed and then invoked.
server.once('connection', (stream) => {
console.log('Ah, we have our first user!');
});
Returns a reference to the EventEmitter, so that calls can be chained.
By default, event listeners are invoked in the order they are added. Theemitter.prependOnceListener() method can be used as an alternative to add the
event listener to the beginning of the listeners array.
const myEE = new EventEmitter();
myEE.once('foo', () => console.log('a'));
myEE.prependOnceListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// a
The callback function
Pauses the processing of this queue only for this worker.
OptionaldoNotWaitActive: booleanResumes processing of this worker (if paused).
Manually starts the stalled checker. The check will run once as soon as this method is called, and then every opts.stalledInterval milliseconds until the worker is closed. Note: Normally you do not need to call this method, since the stalled checker is automatically started when the worker starts processing jobs after calling run. However if you want to process the jobs manually you need to call this method to start the stalled checker.
Wraps the code with telemetry and provides a span for configuration.
kind of the span: Producer, Consumer, Internal
operation name (such as add, process, etc)
destination name (normally the queue name)
code to wrap with telemetry
OptionalsrcPropagationMetadata: stringWaits until the worker is ready to start processing jobs. In general only useful when writing tests.
StaticRate
This class represents a worker that is able to process jobs from the queue. As soon as the class is instantiated and a connection to Redis is established it will start processing jobs.