@avada-falcon/worker-sdk 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/client/client.js +10 -2
package/package.json
CHANGED
package/src/client/client.js
CHANGED
|
@@ -15,7 +15,15 @@ export function createClient(configPath) {
|
|
|
15
15
|
const optsCache = new Map(); // job opts are static per job name — build once
|
|
16
16
|
|
|
17
17
|
return {
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} jobName
|
|
20
|
+
* @param {object} payload
|
|
21
|
+
* @param {{jobId?: string}} [opts] - Caller may supply a readable, unique jobId
|
|
22
|
+
* (e.g. `<job>-<shop>-<rand>`). jobId MUST be unique per dispatch — BullMQ silently
|
|
23
|
+
* drops an add whose id already exists (dedup), so the caller owns collision-resistance.
|
|
24
|
+
* Omitted → a random `<jobName>-<uuid>` is used.
|
|
25
|
+
*/
|
|
26
|
+
async add(jobName, payload, opts = {}) {
|
|
19
27
|
const jobConfig = config.jobs[jobName];
|
|
20
28
|
if (!jobConfig) {
|
|
21
29
|
throw new Error(`Unknown job: ${jobName}. Define it in your worker config.`);
|
|
@@ -28,7 +36,7 @@ export function createClient(configPath) {
|
|
|
28
36
|
|
|
29
37
|
return queue.add(jobName, payload, {
|
|
30
38
|
...optsCache.get(jobName),
|
|
31
|
-
jobId: `${jobName}-${randomUUID()}`
|
|
39
|
+
jobId: opts.jobId || `${jobName}-${randomUUID()}`
|
|
32
40
|
});
|
|
33
41
|
},
|
|
34
42
|
|