@trigger.dev/redis-worker 0.0.0-process-keep-alive-20250618183753 → 0.0.0-process-keep-alive-20250620100954
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/dist/index.cjs +39 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -9645,6 +9645,23 @@ var SimpleQueue = class {
|
|
|
9645
9645
|
throw e;
|
|
9646
9646
|
}
|
|
9647
9647
|
}
|
|
9648
|
+
async getJob(id) {
|
|
9649
|
+
const result = await this.redis.getJob(`queue`, `items`, id);
|
|
9650
|
+
if (!result) {
|
|
9651
|
+
return null;
|
|
9652
|
+
}
|
|
9653
|
+
const [_, score, serializedItem] = result;
|
|
9654
|
+
const item = JSON.parse(serializedItem);
|
|
9655
|
+
return {
|
|
9656
|
+
id,
|
|
9657
|
+
job: item.job,
|
|
9658
|
+
item: item.item,
|
|
9659
|
+
visibilityTimeoutMs: item.visibilityTimeoutMs,
|
|
9660
|
+
attempt: item.attempt ?? 0,
|
|
9661
|
+
timestamp: new Date(Number(score)),
|
|
9662
|
+
deduplicationKey: item.deduplicationKey ?? void 0
|
|
9663
|
+
};
|
|
9664
|
+
}
|
|
9648
9665
|
async moveToDeadLetterQueue(id, errorMessage) {
|
|
9649
9666
|
try {
|
|
9650
9667
|
const result = await this.redis.moveToDeadLetterQueue(
|
|
@@ -9767,6 +9784,25 @@ var SimpleQueue = class {
|
|
|
9767
9784
|
return dequeued
|
|
9768
9785
|
`
|
|
9769
9786
|
});
|
|
9787
|
+
this.redis.defineCommand("getJob", {
|
|
9788
|
+
numberOfKeys: 2,
|
|
9789
|
+
lua: `
|
|
9790
|
+
local queue = KEYS[1]
|
|
9791
|
+
local items = KEYS[2]
|
|
9792
|
+
local jobId = ARGV[1]
|
|
9793
|
+
|
|
9794
|
+
local serializedItem = redis.call('HGET', items, jobId)
|
|
9795
|
+
|
|
9796
|
+
if serializedItem == false then
|
|
9797
|
+
return nil
|
|
9798
|
+
end
|
|
9799
|
+
|
|
9800
|
+
-- get the score from the queue sorted set
|
|
9801
|
+
local score = redis.call('ZSCORE', queue, jobId)
|
|
9802
|
+
|
|
9803
|
+
return { jobId, score, serializedItem }
|
|
9804
|
+
`
|
|
9805
|
+
});
|
|
9770
9806
|
this.redis.defineCommand("ackItem", {
|
|
9771
9807
|
numberOfKeys: 2,
|
|
9772
9808
|
lua: `
|
|
@@ -11265,6 +11301,9 @@ var Worker = class _Worker {
|
|
|
11265
11301
|
}
|
|
11266
11302
|
);
|
|
11267
11303
|
}
|
|
11304
|
+
async getJob(id) {
|
|
11305
|
+
return this.queue.getJob(id);
|
|
11306
|
+
}
|
|
11268
11307
|
/**
|
|
11269
11308
|
* The main loop that each worker runs. It repeatedly polls for items,
|
|
11270
11309
|
* processes them, and then waits before the next iteration.
|