@@ -28,6 +28,7 @@ type JobHandler<Catalog extends WorkerCatalog, K extends keyof Catalog> = (param
28
28
payload : z . infer < Catalog [ K ] [ "schema" ] > ;
29
29
visibilityTimeoutMs : number ;
30
30
attempt : number ;
31
+ deduplicationKey ?: string ;
31
32
} ) => Promise < void > ;
32
33
33
34
export type WorkerConcurrencyOptions = {
@@ -345,7 +346,7 @@ class Worker<TCatalog extends WorkerCatalog> {
345
346
* Processes a single item.
346
347
*/
347
348
private async processItem (
348
- { id, job, item, visibilityTimeoutMs, attempt, timestamp } : AnyQueueItem ,
349
+ { id, job, item, visibilityTimeoutMs, attempt, timestamp, deduplicationKey } : AnyQueueItem ,
349
350
batchSize : number ,
350
351
workerId : string
351
352
) : Promise < void > {
@@ -362,7 +363,7 @@ class Worker<TCatalog extends WorkerCatalog> {
362
363
async ( ) => {
363
364
await this . withHistogram (
364
365
this . metrics . jobDuration ,
365
- handler ( { id, payload : item , visibilityTimeoutMs, attempt } ) ,
366
+ handler ( { id, payload : item , visibilityTimeoutMs, attempt, deduplicationKey } ) ,
366
367
{
367
368
worker_id : workerId ,
368
369
batch_size : batchSize ,
@@ -372,7 +373,7 @@ class Worker<TCatalog extends WorkerCatalog> {
372
373
) ;
373
374
374
375
// On success, acknowledge the item.
375
- await this . queue . ack ( id ) ;
376
+ await this . queue . ack ( id , deduplicationKey ) ;
376
377
} ,
377
378
{
378
379
kind : SpanKind . CONSUMER ,
0 commit comments