@avada-falcon/worker-sdk 0.5.2 → 0.5.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avada-falcon/worker-sdk",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Self-hosted background job runner powered by BullMQ + Redis",
5
5
  "type": "module",
6
6
  "main": "src/index.cjs",
@@ -18,10 +18,12 @@ export function createClient(configPath) {
18
18
  /**
19
19
  * @param {string} jobName
20
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.
21
+ * @param {{jobId?: string, priority?: number}} [opts] - Caller may supply:
22
+ * - jobId: a readable, unique id (e.g. `<job>-<shop>-<rand>`). MUST be unique per
23
+ * dispatch — BullMQ silently drops an add whose id already exists (dedup), so the
24
+ * caller owns collision-resistance. Omitted → a random `<jobName>-<uuid>`.
25
+ * - priority: BullMQ job priority (lower = higher; runs earlier in the wait list).
26
+ * Omitted → no priority (BullMQ default FIFO).
25
27
  */
26
28
  async add(jobName, payload, opts = {}) {
27
29
  const jobConfig = config.jobs[jobName];
@@ -36,7 +38,8 @@ export function createClient(configPath) {
36
38
 
37
39
  return queue.add(jobName, payload, {
38
40
  ...optsCache.get(jobName),
39
- jobId: opts.jobId || `${jobName}-${randomUUID()}`
41
+ jobId: opts.jobId || `${jobName}-${randomUUID()}`,
42
+ ...(opts.priority != null ? {priority: opts.priority} : {})
40
43
  });
41
44
  },
42
45