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.
- package/README.md +21 -21
- package/dist/cjs/classes/flow-producer.js +1 -0
- package/dist/cjs/classes/flow-producer.js.map +1 -1
- package/dist/cjs/classes/job-scheduler.js +14 -0
- package/dist/cjs/classes/job-scheduler.js.map +1 -1
- package/dist/cjs/classes/job.js +61 -41
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/queue-base.js +54 -0
- package/dist/cjs/classes/queue-base.js.map +1 -1
- package/dist/cjs/classes/queue-events.js.map +1 -1
- package/dist/cjs/classes/queue.js +172 -76
- package/dist/cjs/classes/queue.js.map +1 -1
- package/dist/cjs/classes/worker.js +232 -128
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +2 -2
- package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeeded.lua +14 -0
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +3 -3
- package/dist/cjs/commands/moveToFinished-14.lua +2 -2
- package/dist/cjs/commands/updateJobOption-1.lua +26 -0
- package/dist/cjs/enums/index.js +1 -0
- package/dist/cjs/enums/index.js.map +1 -1
- package/dist/cjs/enums/telemetry-attributes.js +45 -0
- package/dist/cjs/enums/telemetry-attributes.js.map +1 -0
- package/dist/cjs/interfaces/index.js +1 -0
- package/dist/cjs/interfaces/index.js.map +1 -1
- package/dist/cjs/interfaces/queue-options.js.map +1 -1
- package/dist/cjs/interfaces/telemetry.js +3 -0
- package/dist/cjs/interfaces/telemetry.js.map +1 -0
- package/dist/cjs/scripts/index.js +1 -0
- package/dist/cjs/scripts/index.js.map +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +9 -9
- package/dist/cjs/scripts/moveToFinished-14.js +8 -8
- package/dist/cjs/scripts/updateJobOption-1.js +30 -0
- package/dist/cjs/scripts/updateJobOption-1.js.map +1 -0
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/flow-producer.js +1 -0
- package/dist/esm/classes/flow-producer.js.map +1 -1
- package/dist/esm/classes/job-scheduler.d.ts +2 -1
- package/dist/esm/classes/job-scheduler.js +14 -0
- package/dist/esm/classes/job-scheduler.js.map +1 -1
- package/dist/esm/classes/job.d.ts +2 -0
- package/dist/esm/classes/job.js +61 -41
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/queue-base.d.ts +19 -1
- package/dist/esm/classes/queue-base.js +54 -0
- package/dist/esm/classes/queue-base.js.map +1 -1
- package/dist/esm/classes/queue-events.js.map +1 -1
- package/dist/esm/classes/queue.d.ts +6 -0
- package/dist/esm/classes/queue.js +172 -76
- package/dist/esm/classes/queue.js.map +1 -1
- package/dist/esm/classes/worker.d.ts +2 -1
- package/dist/esm/classes/worker.js +232 -128
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +2 -2
- package/dist/esm/commands/includes/removeDeduplicationKeyIfNeeded.lua +14 -0
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +3 -3
- package/dist/esm/commands/moveToFinished-14.lua +2 -2
- package/dist/esm/commands/updateJobOption-1.lua +26 -0
- package/dist/esm/enums/index.d.ts +1 -0
- package/dist/esm/enums/index.js +1 -0
- package/dist/esm/enums/index.js.map +1 -1
- package/dist/esm/enums/telemetry-attributes.d.ts +39 -0
- package/dist/esm/enums/telemetry-attributes.js +42 -0
- package/dist/esm/enums/telemetry-attributes.js.map +1 -0
- package/dist/esm/interfaces/base-job-options.d.ts +4 -0
- package/dist/esm/interfaces/index.d.ts +1 -0
- package/dist/esm/interfaces/index.js +1 -0
- package/dist/esm/interfaces/index.js.map +1 -1
- package/dist/esm/interfaces/queue-options.d.ts +9 -0
- package/dist/esm/interfaces/queue-options.js.map +1 -1
- package/dist/esm/interfaces/repeatable-job.d.ts +1 -1
- package/dist/esm/interfaces/telemetry.d.ts +150 -0
- package/dist/esm/interfaces/telemetry.js +2 -0
- package/dist/esm/interfaces/telemetry.js.map +1 -0
- package/dist/esm/interfaces/worker-options.d.ts +13 -0
- package/dist/esm/scripts/index.d.ts +1 -0
- package/dist/esm/scripts/index.js +1 -0
- package/dist/esm/scripts/index.js.map +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +9 -9
- package/dist/esm/scripts/moveToFinished-14.js +8 -8
- package/dist/esm/scripts/updateJobOption-1.d.ts +5 -0
- package/dist/esm/scripts/updateJobOption-1.js +27 -0
- package/dist/esm/scripts/updateJobOption-1.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/types/job-options.d.ts +4 -0
- package/dist/esm/types/minimal-queue.d.ts +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/commands/includes/removeDebounceKeyIfNeeded.lua +0 -14
- 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/
|
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
|
-
|
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
|
package/dist/esm/enums/index.js
CHANGED
@@ -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"}
|
@@ -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":"
|
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"}
|
@@ -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 @@
|
|
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
|
174
|
+
Function to remove deduplication key if needed.
|
175
175
|
]]
|
176
|
-
local function
|
177
|
-
if
|
178
|
-
local
|
179
|
-
local pttl = rcall("PTTL",
|
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",
|
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
|
-
|
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
|
-
|
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
|
267
|
+
Function to remove deduplication key if needed.
|
268
268
|
]]
|
269
|
-
local function
|
270
|
-
if
|
271
|
-
local
|
272
|
-
local pttl = rcall("PTTL",
|
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",
|
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
|
-
|
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
|
-
|
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,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"}
|