bullmq 5.21.2 → 5.23.0

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.
Files changed (92) hide show
  1. package/README.md +21 -21
  2. package/dist/cjs/classes/flow-producer.js +1 -0
  3. package/dist/cjs/classes/flow-producer.js.map +1 -1
  4. package/dist/cjs/classes/job-scheduler.js +14 -0
  5. package/dist/cjs/classes/job-scheduler.js.map +1 -1
  6. package/dist/cjs/classes/job.js +61 -41
  7. package/dist/cjs/classes/job.js.map +1 -1
  8. package/dist/cjs/classes/queue-base.js +54 -0
  9. package/dist/cjs/classes/queue-base.js.map +1 -1
  10. package/dist/cjs/classes/queue-events.js.map +1 -1
  11. package/dist/cjs/classes/queue.js +172 -76
  12. package/dist/cjs/classes/queue.js.map +1 -1
  13. package/dist/cjs/classes/worker.js +232 -128
  14. package/dist/cjs/classes/worker.js.map +1 -1
  15. package/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +2 -2
  16. package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeeded.lua +14 -0
  17. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +3 -3
  18. package/dist/cjs/commands/moveToFinished-14.lua +2 -2
  19. package/dist/cjs/commands/updateJobOption-1.lua +26 -0
  20. package/dist/cjs/enums/index.js +1 -0
  21. package/dist/cjs/enums/index.js.map +1 -1
  22. package/dist/cjs/enums/telemetry-attributes.js +45 -0
  23. package/dist/cjs/enums/telemetry-attributes.js.map +1 -0
  24. package/dist/cjs/interfaces/index.js +1 -0
  25. package/dist/cjs/interfaces/index.js.map +1 -1
  26. package/dist/cjs/interfaces/queue-options.js.map +1 -1
  27. package/dist/cjs/interfaces/telemetry.js +3 -0
  28. package/dist/cjs/interfaces/telemetry.js.map +1 -0
  29. package/dist/cjs/scripts/index.js +1 -0
  30. package/dist/cjs/scripts/index.js.map +1 -1
  31. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +9 -9
  32. package/dist/cjs/scripts/moveToFinished-14.js +8 -8
  33. package/dist/cjs/scripts/updateJobOption-1.js +30 -0
  34. package/dist/cjs/scripts/updateJobOption-1.js.map +1 -0
  35. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  36. package/dist/cjs/version.js +1 -1
  37. package/dist/esm/classes/flow-producer.js +1 -0
  38. package/dist/esm/classes/flow-producer.js.map +1 -1
  39. package/dist/esm/classes/job-scheduler.d.ts +2 -1
  40. package/dist/esm/classes/job-scheduler.js +14 -0
  41. package/dist/esm/classes/job-scheduler.js.map +1 -1
  42. package/dist/esm/classes/job.d.ts +2 -0
  43. package/dist/esm/classes/job.js +61 -41
  44. package/dist/esm/classes/job.js.map +1 -1
  45. package/dist/esm/classes/queue-base.d.ts +19 -1
  46. package/dist/esm/classes/queue-base.js +54 -0
  47. package/dist/esm/classes/queue-base.js.map +1 -1
  48. package/dist/esm/classes/queue-events.js.map +1 -1
  49. package/dist/esm/classes/queue.d.ts +6 -0
  50. package/dist/esm/classes/queue.js +172 -76
  51. package/dist/esm/classes/queue.js.map +1 -1
  52. package/dist/esm/classes/worker.d.ts +2 -1
  53. package/dist/esm/classes/worker.js +232 -128
  54. package/dist/esm/classes/worker.js.map +1 -1
  55. package/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +2 -2
  56. package/dist/esm/commands/includes/removeDeduplicationKeyIfNeeded.lua +14 -0
  57. package/dist/esm/commands/moveStalledJobsToWait-9.lua +3 -3
  58. package/dist/esm/commands/moveToFinished-14.lua +2 -2
  59. package/dist/esm/commands/updateJobOption-1.lua +26 -0
  60. package/dist/esm/enums/index.d.ts +1 -0
  61. package/dist/esm/enums/index.js +1 -0
  62. package/dist/esm/enums/index.js.map +1 -1
  63. package/dist/esm/enums/telemetry-attributes.d.ts +39 -0
  64. package/dist/esm/enums/telemetry-attributes.js +42 -0
  65. package/dist/esm/enums/telemetry-attributes.js.map +1 -0
  66. package/dist/esm/interfaces/base-job-options.d.ts +4 -0
  67. package/dist/esm/interfaces/index.d.ts +1 -0
  68. package/dist/esm/interfaces/index.js +1 -0
  69. package/dist/esm/interfaces/index.js.map +1 -1
  70. package/dist/esm/interfaces/queue-options.d.ts +9 -0
  71. package/dist/esm/interfaces/queue-options.js.map +1 -1
  72. package/dist/esm/interfaces/repeatable-job.d.ts +1 -1
  73. package/dist/esm/interfaces/telemetry.d.ts +150 -0
  74. package/dist/esm/interfaces/telemetry.js +2 -0
  75. package/dist/esm/interfaces/telemetry.js.map +1 -0
  76. package/dist/esm/interfaces/worker-options.d.ts +13 -0
  77. package/dist/esm/scripts/index.d.ts +1 -0
  78. package/dist/esm/scripts/index.js +1 -0
  79. package/dist/esm/scripts/index.js.map +1 -1
  80. package/dist/esm/scripts/moveStalledJobsToWait-9.js +9 -9
  81. package/dist/esm/scripts/moveToFinished-14.js +8 -8
  82. package/dist/esm/scripts/updateJobOption-1.d.ts +5 -0
  83. package/dist/esm/scripts/updateJobOption-1.js +27 -0
  84. package/dist/esm/scripts/updateJobOption-1.js.map +1 -0
  85. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  86. package/dist/esm/types/job-options.d.ts +4 -0
  87. package/dist/esm/types/minimal-queue.d.ts +1 -1
  88. package/dist/esm/version.d.ts +1 -1
  89. package/dist/esm/version.js +1 -1
  90. package/package.json +2 -2
  91. package/dist/cjs/commands/includes/removeDebounceKeyIfNeeded.lua +0 -14
  92. package/dist/esm/commands/includes/removeDebounceKeyIfNeeded.lua +0 -14
@@ -65,7 +65,7 @@ local rcall = redis.call
65
65
  --- @include "includes/moveParentToWaitIfNeeded"
66
66
  --- @include "includes/prepareJobForProcessing"
67
67
  --- @include "includes/promoteDelayedJobs"
68
- --- @include "includes/removeDebounceKeyIfNeeded"
68
+ --- @include "includes/removeDeduplicationKeyIfNeeded"
69
69
  --- @include "includes/removeJobKeys"
70
70
  --- @include "includes/removeJobsByMaxAge"
71
71
  --- @include "includes/removeJobsByMaxCount"
@@ -119,7 +119,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
119
119
 
120
120
  local prefix = ARGV[7]
121
121
 
122
- removeDebounceKeyIfNeeded(prefix, jobAttributes[3])
122
+ removeDeduplicationKeyIfNeeded(prefix, jobAttributes[3])
123
123
 
124
124
  -- If job has a parent we need to
125
125
  -- 1) remove this job id from parents dependencies
@@ -0,0 +1,26 @@
1
+ --[[
2
+ Update a job option
3
+
4
+ Input:
5
+ KEYS[1] Job id key
6
+
7
+ ARGV[1] field
8
+ ARGV[2] value
9
+
10
+ Output:
11
+ 0 - OK
12
+ -1 - Missing job.
13
+ ]]
14
+ local rcall = redis.call
15
+
16
+ if rcall("EXISTS", KEYS[1]) == 1 then -- // Make sure job exists
17
+
18
+ local opts = rcall("HGET", KEYS[1], "opts")
19
+ local jsonOpts = cjson.decode(opts)
20
+ jsonOpts[ARGV[1]] = ARGV[2]
21
+
22
+ rcall("HSET", KEYS[1], "opts", cjson.encode(jsonOpts))
23
+ return 0
24
+ else
25
+ return -1
26
+ end
@@ -2,3 +2,4 @@ export * from './child-command';
2
2
  export * from './error-code';
3
3
  export * from './parent-command';
4
4
  export * from './metrics-time';
5
+ export * from './telemetry-attributes';
@@ -2,4 +2,5 @@ export * from './child-command';
2
2
  export * from './error-code';
3
3
  export * from './parent-command';
4
4
  export * from './metrics-time';
5
+ export * from './telemetry-attributes';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enums/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enums/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,39 @@
1
+ export declare enum TelemetryAttributes {
2
+ QueueName = "bullmq.queue.name",
3
+ QueueOperation = "bullmq.queue.operation",
4
+ BulkCount = "bullmq.job.bulk.count",
5
+ BulkNames = "bullmq.job.bulk.names",
6
+ JobName = "bullmq.job.name",
7
+ JobId = "bullmq.job.id",
8
+ JobKey = "bullmq.job.key",
9
+ JobIds = "bullmq.job.ids",
10
+ DeduplicationKey = "bullmq.job.deduplication.key",
11
+ JobOptions = "bullmq.job.options",
12
+ JobProgress = "bullmq.job.progress",
13
+ QueueDrainDelay = "bullmq.queue.drain.delay",
14
+ QueueGrace = "bullmq.queue.grace",
15
+ QueueCleanLimit = "bullmq.queue.clean.limit",
16
+ JobType = "bullmq.job.type",
17
+ QueueOptions = "bullmq.queue.options",
18
+ QueueEventMaxLength = "bullmq.queue.event.max.length",
19
+ WorkerOptions = "bullmq.worker.options",
20
+ WorkerName = "bullmq.worker.name",
21
+ WorkerId = "bullmq.worker.id",
22
+ WorkerRateLimit = "bullmq.worker.rate.limit",
23
+ WorkerDoNotWaitActive = "bullmq.worker.do.not.wait.active",
24
+ WorkerForceClose = "bullmq.worker.force.close",
25
+ WorkerStalledJobs = "bullmq.worker.stalled.jobs",
26
+ WorkerFailedJobs = "bullmq.worker.failed.jobs",
27
+ WorkerJobsToExtendLocks = "bullmq.worker.jobs.to.extend.locks",
28
+ JobFinishedTimestamp = "bullmq.job.finished.timestamp",
29
+ JobProcessedTimestamp = "bullmq.job.processed.timestamp",
30
+ JobResult = "bullmq.job.result",
31
+ JobFailedReason = "bullmq.job.failed.reason"
32
+ }
33
+ export declare enum SpanKind {
34
+ INTERNAL = 0,
35
+ SERVER = 1,
36
+ CLIENT = 2,
37
+ PRODUCER = 3,
38
+ CONSUMER = 4
39
+ }
@@ -0,0 +1,42 @@
1
+ export var TelemetryAttributes;
2
+ (function (TelemetryAttributes) {
3
+ TelemetryAttributes["QueueName"] = "bullmq.queue.name";
4
+ TelemetryAttributes["QueueOperation"] = "bullmq.queue.operation";
5
+ TelemetryAttributes["BulkCount"] = "bullmq.job.bulk.count";
6
+ TelemetryAttributes["BulkNames"] = "bullmq.job.bulk.names";
7
+ TelemetryAttributes["JobName"] = "bullmq.job.name";
8
+ TelemetryAttributes["JobId"] = "bullmq.job.id";
9
+ TelemetryAttributes["JobKey"] = "bullmq.job.key";
10
+ TelemetryAttributes["JobIds"] = "bullmq.job.ids";
11
+ TelemetryAttributes["DeduplicationKey"] = "bullmq.job.deduplication.key";
12
+ TelemetryAttributes["JobOptions"] = "bullmq.job.options";
13
+ TelemetryAttributes["JobProgress"] = "bullmq.job.progress";
14
+ TelemetryAttributes["QueueDrainDelay"] = "bullmq.queue.drain.delay";
15
+ TelemetryAttributes["QueueGrace"] = "bullmq.queue.grace";
16
+ TelemetryAttributes["QueueCleanLimit"] = "bullmq.queue.clean.limit";
17
+ TelemetryAttributes["JobType"] = "bullmq.job.type";
18
+ TelemetryAttributes["QueueOptions"] = "bullmq.queue.options";
19
+ TelemetryAttributes["QueueEventMaxLength"] = "bullmq.queue.event.max.length";
20
+ TelemetryAttributes["WorkerOptions"] = "bullmq.worker.options";
21
+ TelemetryAttributes["WorkerName"] = "bullmq.worker.name";
22
+ TelemetryAttributes["WorkerId"] = "bullmq.worker.id";
23
+ TelemetryAttributes["WorkerRateLimit"] = "bullmq.worker.rate.limit";
24
+ TelemetryAttributes["WorkerDoNotWaitActive"] = "bullmq.worker.do.not.wait.active";
25
+ TelemetryAttributes["WorkerForceClose"] = "bullmq.worker.force.close";
26
+ TelemetryAttributes["WorkerStalledJobs"] = "bullmq.worker.stalled.jobs";
27
+ TelemetryAttributes["WorkerFailedJobs"] = "bullmq.worker.failed.jobs";
28
+ TelemetryAttributes["WorkerJobsToExtendLocks"] = "bullmq.worker.jobs.to.extend.locks";
29
+ TelemetryAttributes["JobFinishedTimestamp"] = "bullmq.job.finished.timestamp";
30
+ TelemetryAttributes["JobProcessedTimestamp"] = "bullmq.job.processed.timestamp";
31
+ TelemetryAttributes["JobResult"] = "bullmq.job.result";
32
+ TelemetryAttributes["JobFailedReason"] = "bullmq.job.failed.reason";
33
+ })(TelemetryAttributes || (TelemetryAttributes = {}));
34
+ export var SpanKind;
35
+ (function (SpanKind) {
36
+ SpanKind[SpanKind["INTERNAL"] = 0] = "INTERNAL";
37
+ SpanKind[SpanKind["SERVER"] = 1] = "SERVER";
38
+ SpanKind[SpanKind["CLIENT"] = 2] = "CLIENT";
39
+ SpanKind[SpanKind["PRODUCER"] = 3] = "PRODUCER";
40
+ SpanKind[SpanKind["CONSUMER"] = 4] = "CONSUMER";
41
+ })(SpanKind || (SpanKind = {}));
42
+ //# sourceMappingURL=telemetry-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry-attributes.js","sourceRoot":"","sources":["../../../src/enums/telemetry-attributes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBA+BX;AA/BD,WAAY,mBAAmB;IAC7B,sDAA+B,CAAA;IAC/B,gEAAyC,CAAA;IACzC,0DAAmC,CAAA;IACnC,0DAAmC,CAAA;IACnC,kDAA2B,CAAA;IAC3B,8CAAuB,CAAA;IACvB,gDAAyB,CAAA;IACzB,gDAAyB,CAAA;IACzB,wEAAiD,CAAA;IACjD,wDAAiC,CAAA;IACjC,0DAAmC,CAAA;IACnC,mEAA4C,CAAA;IAC5C,wDAAiC,CAAA;IACjC,mEAA4C,CAAA;IAC5C,kDAA2B,CAAA;IAC3B,4DAAqC,CAAA;IACrC,4EAAqD,CAAA;IACrD,8DAAuC,CAAA;IACvC,wDAAiC,CAAA;IACjC,oDAA6B,CAAA;IAC7B,mEAA4C,CAAA;IAC5C,iFAA0D,CAAA;IAC1D,qEAA8C,CAAA;IAC9C,uEAAgD,CAAA;IAChD,qEAA8C,CAAA;IAC9C,qFAA8D,CAAA;IAC9D,6EAAsD,CAAA;IACtD,+EAAwD,CAAA;IACxD,sDAA+B,CAAA;IAC/B,mEAA4C,CAAA;AAC9C,CAAC,EA/BW,mBAAmB,KAAnB,mBAAmB,QA+B9B;AAED,MAAM,CAAN,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,+CAAY,CAAA;IACZ,2CAAU,CAAA;IACV,2CAAU,CAAA;IACV,+CAAY,CAAA;IACZ,+CAAY,CAAA;AACd,CAAC,EANW,QAAQ,KAAR,QAAQ,QAMnB"}
@@ -95,4 +95,8 @@ export interface BaseJobOptions extends DefaultJobOptions {
95
95
  * Internal property used by repeatable jobs.
96
96
  */
97
97
  prevMillis?: number;
98
+ /**
99
+ * TelemetryMetadata, provide for context propagation.
100
+ */
101
+ telemetryMetadata?: string;
98
102
  }
@@ -24,3 +24,4 @@ export * from './sandboxed-job-processor';
24
24
  export * from './sandboxed-job';
25
25
  export * from './sandboxed-options';
26
26
  export * from './worker-options';
27
+ export * from './telemetry';
@@ -24,4 +24,5 @@ export * from './sandboxed-job-processor';
24
24
  export * from './sandboxed-job';
25
25
  export * from './sandboxed-options';
26
26
  export * from './worker-options';
27
+ export * from './telemetry';
27
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { AdvancedRepeatOptions } from './advanced-options';
2
2
  import { DefaultJobOptions } from './base-job-options';
3
3
  import { ConnectionOptions } from './redis-options';
4
+ import { Telemetry } from './telemetry';
4
5
  export declare enum ClientType {
5
6
  blocking = "blocking",
6
7
  normal = "normal"
@@ -26,6 +27,10 @@ export interface QueueBaseOptions {
26
27
  * @defaultValue false
27
28
  */
28
29
  skipVersionCheck?: boolean;
30
+ /**
31
+ * Telemetry client
32
+ */
33
+ telemetry?: Telemetry;
29
34
  }
30
35
  /**
31
36
  * Options for the Queue class.
@@ -59,6 +64,10 @@ export interface QueueOptions extends QueueBaseOptions {
59
64
  * Advanced options for the repeatable jobs.
60
65
  */
61
66
  settings?: AdvancedRepeatOptions;
67
+ /**
68
+ * Telemetry client
69
+ */
70
+ telemetry?: Telemetry;
62
71
  }
63
72
  /**
64
73
  * Options for the Repeat class.
@@ -1 +1 @@
1
- {"version":3,"file":"queue-options.js","sourceRoot":"","sources":["../../../src/interfaces/queue-options.ts"],"names":[],"mappings":"AAIA,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,+BAAiB,CAAA;AACnB,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB"}
1
+ {"version":3,"file":"queue-options.js","sourceRoot":"","sources":["../../../src/interfaces/queue-options.ts"],"names":[],"mappings":"AAKA,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,+BAAiB,CAAA;AACnB,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB"}
@@ -6,5 +6,5 @@ export type RepeatableJob = {
6
6
  tz: string | null;
7
7
  pattern: string | null;
8
8
  every?: string | null;
9
- next: number;
9
+ next?: number;
10
10
  };
@@ -0,0 +1,150 @@
1
+ import { SpanKind } from '../enums';
2
+ /**
3
+ * Telemetry interface
4
+ *
5
+ * This interface allows third-party libraries to integrate their own telemetry
6
+ * system. The interface is heavily inspired by OpenTelemetry but it's not
7
+ * limited to it.
8
+ *
9
+ */
10
+ export interface Telemetry<Context = any> {
11
+ /**
12
+ * Tracer instance
13
+ *
14
+ * The tracer is responsible for creating spans and propagating the context
15
+ * across the application.
16
+ */
17
+ tracer: Tracer<Context>;
18
+ /**
19
+ * Context manager instance
20
+ *
21
+ * The context manager is responsible for managing the context and propagating
22
+ * it across the application.
23
+ */
24
+ contextManager: ContextManager;
25
+ }
26
+ /**
27
+ * Context manager interface
28
+ *
29
+ * The context manager is responsible for managing the context and propagating
30
+ * it across the application.
31
+ */
32
+ export interface ContextManager<Context = any> {
33
+ /**
34
+ * Creates a new context and sets it as active for the fn passed as last argument
35
+ *
36
+ * @param context
37
+ * @param fn
38
+ */
39
+ with<A extends (...args: any[]) => any>(context: Context, fn: A): ReturnType<A>;
40
+ /**
41
+ * Returns the active context
42
+ */
43
+ active(): Context;
44
+ /**
45
+ * Returns a serialized version of the current context. The metadata
46
+ * is the mechanism used to propagate the context across a distributed
47
+ * application.
48
+ *
49
+ * @param context
50
+ */
51
+ getMetadata(context: Context): string;
52
+ /**
53
+ * Creates a new context from a serialized version effectively
54
+ * linking the new context to the parent context.
55
+ *
56
+ * @param activeContext
57
+ * @param metadata
58
+ */
59
+ fromMetadata(activeContext: Context, metadata: string): Context;
60
+ }
61
+ /**
62
+ * Tracer interface
63
+ *
64
+ */
65
+ export interface Tracer<Context = any> {
66
+ /**
67
+ * startSpan creates a new Span with the given name and options on an optional
68
+ * context. If the context is not provided, the current active context should be
69
+ * used.
70
+ *
71
+ * @param name
72
+ * @param options
73
+ * @param context
74
+ */
75
+ startSpan(name: string, options?: SpanOptions, context?: Context): Span;
76
+ }
77
+ export interface SpanOptions {
78
+ kind: SpanKind;
79
+ }
80
+ /**
81
+ * Span interface
82
+ */
83
+ export interface Span<Context = any> {
84
+ /**
85
+ * setSpanOnContext sets the span on the context. This is useful when you want
86
+ * to propagate the span across the application.
87
+ *
88
+ * @param ctx
89
+ */
90
+ setSpanOnContext(ctx: Context): Context;
91
+ /**
92
+ * setAttribute sets an attribute on the span.
93
+ *
94
+ * @param ctx
95
+ */
96
+ setAttribute(key: string, value: AttributeValue): void;
97
+ /**
98
+ * setAttributes sets multiple attributes on the span.
99
+ *
100
+ * @param attributes
101
+ */
102
+ setAttributes(attributes: Attributes): void;
103
+ /**
104
+ * addEvent adds an event to the span.
105
+ *
106
+ * @param name
107
+ * @param attributes
108
+ */
109
+ addEvent(name: string, attributes?: Attributes): void;
110
+ /**
111
+ * recordException records an exception on the span.
112
+ *
113
+ * @param exception
114
+ * @param time
115
+ */
116
+ recordException(exception: Exception, time?: Time): void;
117
+ /**
118
+ * end ends the span.
119
+ *
120
+ * Note: spans must be ended so that they can be exported.
121
+ */
122
+ end(): void;
123
+ }
124
+ export interface Attributes {
125
+ [attribute: string]: AttributeValue | undefined;
126
+ }
127
+ export type AttributeValue = string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>;
128
+ export type Exception = string | ExceptionType;
129
+ export type ExceptionType = CodeException | MessageException | NameException;
130
+ interface CodeException {
131
+ code: string | number;
132
+ name?: string;
133
+ message?: string;
134
+ stack?: string;
135
+ }
136
+ interface MessageException {
137
+ code?: string | number;
138
+ name?: string;
139
+ message: string;
140
+ stack?: string;
141
+ }
142
+ interface NameException {
143
+ code?: string | number;
144
+ name: string;
145
+ message?: string;
146
+ stack?: string;
147
+ }
148
+ export type Time = HighResolutionTime | number | Date;
149
+ type HighResolutionTime = [number, number];
150
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=telemetry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../../src/interfaces/telemetry.ts"],"names":[],"mappings":""}
@@ -4,6 +4,7 @@ import { QueueBaseOptions } from './queue-options';
4
4
  import { RateLimiterOptions } from './rate-limiter-options';
5
5
  import { MetricsOptions } from './metrics-options';
6
6
  import { KeepJobs } from './keep-jobs';
7
+ import { Telemetry } from './telemetry';
7
8
  import { SandboxedOptions } from './sandboxed-options';
8
9
  /**
9
10
  * An async function that receives `Job`s and handles them.
@@ -116,6 +117,18 @@ export interface WorkerOptions extends QueueBaseOptions, SandboxedOptions {
116
117
  * More advanced options.
117
118
  */
118
119
  settings?: AdvancedOptions;
120
+ /**
121
+ * Use Worker Threads instead of Child Processes.
122
+ * Note: This option can only be used when specifying
123
+ * a file for the processor argument.
124
+ *
125
+ * @default false
126
+ */
127
+ useWorkerThreads?: boolean;
128
+ /**
129
+ * Telemetry Addon
130
+ */
131
+ telemetry?: Telemetry;
119
132
  }
120
133
  export interface GetNextJobOptions {
121
134
  block?: boolean;
@@ -39,5 +39,6 @@ export * from './reprocessJob-8';
39
39
  export * from './retryJob-11';
40
40
  export * from './saveStacktrace-1';
41
41
  export * from './updateData-1';
42
+ export * from './updateJobOption-1';
42
43
  export * from './updateProgress-3';
43
44
  export * from './updateRepeatableJobMillis-1';
@@ -39,6 +39,7 @@ export * from './reprocessJob-8';
39
39
  export * from './retryJob-11';
40
40
  export * from './saveStacktrace-1';
41
41
  export * from './updateData-1';
42
+ export * from './updateJobOption-1';
42
43
  export * from './updateProgress-3';
43
44
  export * from './updateRepeatableJobMillis-1';
44
45
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC"}
@@ -171,14 +171,14 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
171
171
  end
172
172
  end
173
173
  --[[
174
- Function to remove debounce key if needed.
174
+ Function to remove deduplication key if needed.
175
175
  ]]
176
- local function removeDebounceKeyIfNeeded(prefixKey, debounceId)
177
- if debounceId then
178
- local debounceKey = prefixKey .. "de:" .. debounceId
179
- local pttl = rcall("PTTL", debounceKey)
176
+ local function removeDeduplicationKeyIfNeeded(prefixKey, deduplicationId)
177
+ if deduplicationId then
178
+ local deduplicationKey = prefixKey .. "de:" .. deduplicationId
179
+ local pttl = rcall("PTTL", deduplicationKey)
180
180
  if pttl == 0 or pttl == -1 then
181
- rcall("DEL", debounceKey)
181
+ rcall("DEL", deduplicationKey)
182
182
  end
183
183
  end
184
184
  end
@@ -190,7 +190,7 @@ local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey,
190
190
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
191
191
  failedReason, "prev", "waiting-children")
192
192
  local jobAttributes = rcall("HMGET", parentKey, "parent", "deid")
193
- removeDebounceKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
193
+ removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
194
194
  if jobAttributes[1] then
195
195
  local parentData = cjson.decode(jobAttributes[1])
196
196
  if parentData['fpof'] then
@@ -427,7 +427,7 @@ if (#stalling > 0) then
427
427
  local opts = cjson.decode(rawOpts)
428
428
  local removeOnFailType = type(opts["removeOnFail"])
429
429
  rcall("ZADD", failedKey, timestamp, jobId)
430
- removeDebounceKeyIfNeeded(queueKeyPrefix, jobAttributes[3])
430
+ removeDeduplicationKeyIfNeeded(queueKeyPrefix, jobAttributes[3])
431
431
  local failedReason =
432
432
  "job stalled more than allowable limit"
433
433
  rcall("HMSET", jobKey, "failedReason", failedReason,
@@ -482,7 +482,7 @@ if (#stalling > 0) then
482
482
  end
483
483
  table.insert(failed, jobId)
484
484
  else
485
- local target, isPausedOrMaxed=
485
+ local target, isPausedOrMaxed =
486
486
  getTargetQueueList(metaKey, activeKey, waitKey, pausedKey)
487
487
  -- Move the job back to the wait queue, to immediately be picked up by a waiting worker.
488
488
  addJobInTargetList(target, markerKey, "RPUSH", isPausedOrMaxed, jobId)
@@ -264,14 +264,14 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
264
264
  end
265
265
  end
266
266
  --[[
267
- Function to remove debounce key if needed.
267
+ Function to remove deduplication key if needed.
268
268
  ]]
269
- local function removeDebounceKeyIfNeeded(prefixKey, debounceId)
270
- if debounceId then
271
- local debounceKey = prefixKey .. "de:" .. debounceId
272
- local pttl = rcall("PTTL", debounceKey)
269
+ local function removeDeduplicationKeyIfNeeded(prefixKey, deduplicationId)
270
+ if deduplicationId then
271
+ local deduplicationKey = prefixKey .. "de:" .. deduplicationId
272
+ local pttl = rcall("PTTL", deduplicationKey)
273
273
  if pttl == 0 or pttl == -1 then
274
- rcall("DEL", debounceKey)
274
+ rcall("DEL", deduplicationKey)
275
275
  end
276
276
  end
277
277
  end
@@ -283,7 +283,7 @@ local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey,
283
283
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
284
284
  failedReason, "prev", "waiting-children")
285
285
  local jobAttributes = rcall("HMGET", parentKey, "parent", "deid")
286
- removeDebounceKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
286
+ removeDeduplicationKeyIfNeeded(parentQueueKey .. ":", jobAttributes[2])
287
287
  if jobAttributes[1] then
288
288
  local parentData = cjson.decode(jobAttributes[1])
289
289
  if parentData['fpof'] then
@@ -603,7 +603,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
603
603
  -- Trim events before emiting them to avoid trimming events emitted in this script
604
604
  trimEvents(metaKey, eventStreamKey)
605
605
  local prefix = ARGV[7]
606
- removeDebounceKeyIfNeeded(prefix, jobAttributes[3])
606
+ removeDeduplicationKeyIfNeeded(prefix, jobAttributes[3])
607
607
  -- If job has a parent we need to
608
608
  -- 1) remove this job id from parents dependencies
609
609
  -- 2) move the job Id to parent "processed" set
@@ -0,0 +1,5 @@
1
+ export declare const updateJobOption: {
2
+ name: string;
3
+ content: string;
4
+ keys: number;
5
+ };
@@ -0,0 +1,27 @@
1
+ const content = `--[[
2
+ Update a job option
3
+ Input:
4
+ KEYS[1] Job id key
5
+ ARGV[1] field
6
+ ARGV[2] value
7
+ Output:
8
+ 0 - OK
9
+ -1 - Missing job.
10
+ ]]
11
+ local rcall = redis.call
12
+ if rcall("EXISTS", KEYS[1]) == 1 then -- // Make sure job exists
13
+ local opts = rcall("HGET", KEYS[1], "opts")
14
+ local jsonOpts = cjson.decode(opts)
15
+ jsonOpts[ARGV[1]] = ARGV[2]
16
+ rcall("HSET", KEYS[1], "opts", cjson.encode(jsonOpts))
17
+ return 0
18
+ else
19
+ return -1
20
+ end
21
+ `;
22
+ export const updateJobOption = {
23
+ name: 'updateJobOption',
24
+ content,
25
+ keys: 1,
26
+ };
27
+ //# sourceMappingURL=updateJobOption-1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateJobOption-1.js","sourceRoot":"","sources":["../../../src/scripts/updateJobOption-1.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;CAoBf,CAAC;AACF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}