MCPcopy Create free account
hub / github.com/actionhero/node-resque / enqueue

Method enqueue

src/core/queue.ts:82–103  ·  view source on GitHub ↗

* - Enqueue a named job (defined in `jobs` to be worked by a worker) * - The job will be added to the `queueName` queue, and that queue will be worked down by available workers assigned to that queue * - args is optional, but should be an array of arguments passed to the job. Order of argument

(q: string, func: string, args: Array<any> = [])

Source from the content-addressed store, hash-verified

80 * - args is optional, but should be an array of arguments passed to the job. Order of arguments is maintained
81 */
82 async enqueue(q: string, func: string, args: Array<any> = []) {
83 args = arrayify(args);
84 const job = this.jobs[func];
85
86 const toRun = await RunPlugins(this, "beforeEnqueue", func, q, job, args);
87 if (toRun === false) return toRun;
88
89 const response = await this.connection.redis
90 .multi()
91 .sadd(this.connection.key("queues"), q)
92 .rpush(this.connection.key("queue", q), this.encode(q, func, args))
93 .exec();
94
95 response?.forEach((res) => {
96 if (res[0] !== null) {
97 throw res[0];
98 }
99 });
100
101 await RunPlugins(this, "afterEnqueue", func, q, job, args);
102 return toRun;
103 }
104
105 /**
106 * - In ms, the unix timestamp at which this job is able to start being worked on.

Callers 15

retryAndRemoveFailedMethod · 0.95
bootFunction · 0.95
bootFunction · 0.95
bootFunction · 0.95
bootFunction · 0.95
bootFunction · 0.95
bootFunction · 0.95
bootFunction · 0.95
bootFunction · 0.95
bootFunction · 0.95
transferMethod · 0.80
bootFunction · 0.80

Calls 4

encodeMethod · 0.95
RunPluginsFunction · 0.90
arrayifyFunction · 0.85
keyMethod · 0.45

Tested by

no test coverage detected