@workglow/job-queue 0.0.68 → 0.0.70
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 +0 -4
- package/dist/browser.js +77 -141
- package/dist/browser.js.map +7 -6
- package/dist/bun.js +77 -141
- package/dist/bun.js.map +7 -6
- package/dist/common.d.ts +1 -0
- package/dist/common.d.ts.map +1 -1
- package/dist/job/JobQueueClient.d.ts +7 -0
- package/dist/job/JobQueueClient.d.ts.map +1 -1
- package/dist/job/JobQueueEventListeners.d.ts +0 -2
- package/dist/job/JobQueueEventListeners.d.ts.map +1 -1
- package/dist/job/JobQueueServer.d.ts +0 -1
- package/dist/job/JobQueueServer.d.ts.map +1 -1
- package/dist/job/JobQueueWorker.d.ts.map +1 -1
- package/dist/job/JobStorageConverters.d.ts +18 -0
- package/dist/job/JobStorageConverters.d.ts.map +1 -0
- package/dist/node.js +77 -141
- package/dist/node.js.map +7 -6
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JobQueueWorker.d.ts","sourceRoot":"","sources":["../../src/job/JobQueueWorker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAa,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAGL,QAAQ,EAIT,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"JobQueueWorker.d.ts","sourceRoot":"","sources":["../../src/job/JobQueueWorker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAa,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAgB,MAA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roussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { JobStorageFormat } from "@workglow/storage";
|
|
7
|
+
import { Job, JobClass } from "./Job";
|
|
8
|
+
/**
|
|
9
|
+
* Convert storage format to Job class
|
|
10
|
+
*/
|
|
11
|
+
export declare function storageToClass<Input, Output>(details: JobStorageFormat<Input, Output>, jobClass: JobClass<Input, Output>, options?: {
|
|
12
|
+
readonly includeWorkerId?: boolean;
|
|
13
|
+
}): Job<Input, Output>;
|
|
14
|
+
/**
|
|
15
|
+
* Convert Job class to storage format
|
|
16
|
+
*/
|
|
17
|
+
export declare function classToStorage<Input, Output>(job: Job<Input, Output>, queueName: string): JobStorageFormat<Input, Output>;
|
|
18
|
+
//# sourceMappingURL=JobStorageConverters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JobStorageConverters.d.ts","sourceRoot":"","sources":["../../src/job/JobStorageConverters.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAa,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAmBtC;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAC1C,OAAO,EAAE,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,EACxC,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,EACjC,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACpC,GACA,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAwBpB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAC1C,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,EACvB,SAAS,EAAE,MAAM,GAChB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAwBjC"}
|
package/dist/node.js
CHANGED
|
@@ -136,6 +136,71 @@ class Job {
|
|
|
136
136
|
// src/job/JobQueueClient.ts
|
|
137
137
|
import { JobStatus as JobStatus2 } from "@workglow/storage";
|
|
138
138
|
import { EventEmitter } from "@workglow/util";
|
|
139
|
+
|
|
140
|
+
// src/job/JobStorageConverters.ts
|
|
141
|
+
function toDate(date) {
|
|
142
|
+
if (!date)
|
|
143
|
+
return null;
|
|
144
|
+
const d = new Date(date);
|
|
145
|
+
return isNaN(d.getTime()) ? null : d;
|
|
146
|
+
}
|
|
147
|
+
function dateToISOString(date) {
|
|
148
|
+
if (!date)
|
|
149
|
+
return null;
|
|
150
|
+
return isNaN(date.getTime()) ? null : date.toISOString();
|
|
151
|
+
}
|
|
152
|
+
function storageToClass(details, jobClass, options) {
|
|
153
|
+
const includeWorkerId = options?.includeWorkerId ?? true;
|
|
154
|
+
return new jobClass({
|
|
155
|
+
id: details.id,
|
|
156
|
+
jobRunId: details.job_run_id,
|
|
157
|
+
queueName: details.queue,
|
|
158
|
+
fingerprint: details.fingerprint,
|
|
159
|
+
input: details.input,
|
|
160
|
+
output: details.output,
|
|
161
|
+
runAfter: toDate(details.run_after),
|
|
162
|
+
createdAt: toDate(details.created_at),
|
|
163
|
+
deadlineAt: toDate(details.deadline_at),
|
|
164
|
+
lastRanAt: toDate(details.last_ran_at),
|
|
165
|
+
completedAt: toDate(details.completed_at),
|
|
166
|
+
progress: details.progress || 0,
|
|
167
|
+
progressMessage: details.progress_message || "",
|
|
168
|
+
progressDetails: details.progress_details ?? null,
|
|
169
|
+
status: details.status,
|
|
170
|
+
error: details.error ?? null,
|
|
171
|
+
errorCode: details.error_code ?? null,
|
|
172
|
+
runAttempts: details.run_attempts ?? 0,
|
|
173
|
+
maxRetries: details.max_retries ?? 10,
|
|
174
|
+
...includeWorkerId ? { workerId: details.worker_id ?? null } : {}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
function classToStorage(job, queueName) {
|
|
178
|
+
const now = new Date().toISOString();
|
|
179
|
+
return {
|
|
180
|
+
id: job.id,
|
|
181
|
+
job_run_id: job.jobRunId,
|
|
182
|
+
queue: job.queueName || queueName,
|
|
183
|
+
fingerprint: job.fingerprint,
|
|
184
|
+
input: job.input,
|
|
185
|
+
status: job.status,
|
|
186
|
+
output: job.output ?? null,
|
|
187
|
+
error: job.error === null ? null : String(job.error),
|
|
188
|
+
error_code: job.errorCode || null,
|
|
189
|
+
run_attempts: job.runAttempts ?? 0,
|
|
190
|
+
max_retries: job.maxRetries ?? 10,
|
|
191
|
+
run_after: dateToISOString(job.runAfter) ?? now,
|
|
192
|
+
created_at: dateToISOString(job.createdAt) ?? now,
|
|
193
|
+
deadline_at: dateToISOString(job.deadlineAt),
|
|
194
|
+
last_ran_at: dateToISOString(job.lastRanAt),
|
|
195
|
+
completed_at: dateToISOString(job.completedAt),
|
|
196
|
+
progress: job.progress ?? 0,
|
|
197
|
+
progress_message: job.progressMessage ?? "",
|
|
198
|
+
progress_details: job.progressDetails ?? null,
|
|
199
|
+
worker_id: job.workerId ?? null
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// src/job/JobQueueClient.ts
|
|
139
204
|
class JobQueueClient {
|
|
140
205
|
queueName;
|
|
141
206
|
storage;
|
|
@@ -266,7 +331,7 @@ class JobQueueClient {
|
|
|
266
331
|
throw new JobNotFoundError("Cannot abort job run with undefined jobRunId");
|
|
267
332
|
const jobs = await this.getJobsByRunId(jobRunId);
|
|
268
333
|
await Promise.allSettled(jobs.map((job) => {
|
|
269
|
-
if (
|
|
334
|
+
if (job.status === JobStatus2.PROCESSING || job.status === JobStatus2.PENDING) {
|
|
270
335
|
return this.abort(job.id);
|
|
271
336
|
}
|
|
272
337
|
}));
|
|
@@ -299,6 +364,9 @@ class JobQueueClient {
|
|
|
299
364
|
waitOn(event) {
|
|
300
365
|
return this.events.waitOn(event);
|
|
301
366
|
}
|
|
367
|
+
subscribe(event, listener) {
|
|
368
|
+
return this.events.subscribe(event, listener);
|
|
369
|
+
}
|
|
302
370
|
handleJobStart(jobId) {
|
|
303
371
|
this.lastKnownProgress.set(jobId, {
|
|
304
372
|
progress: 0,
|
|
@@ -388,33 +456,7 @@ class JobQueueClient {
|
|
|
388
456
|
}
|
|
389
457
|
}
|
|
390
458
|
storageToClass(details) {
|
|
391
|
-
|
|
392
|
-
if (!date)
|
|
393
|
-
return null;
|
|
394
|
-
const d = new Date(date);
|
|
395
|
-
return isNaN(d.getTime()) ? null : d;
|
|
396
|
-
};
|
|
397
|
-
return new Job({
|
|
398
|
-
id: details.id,
|
|
399
|
-
jobRunId: details.job_run_id,
|
|
400
|
-
queueName: details.queue,
|
|
401
|
-
fingerprint: details.fingerprint,
|
|
402
|
-
input: details.input,
|
|
403
|
-
output: details.output,
|
|
404
|
-
runAfter: toDate(details.run_after),
|
|
405
|
-
createdAt: toDate(details.created_at),
|
|
406
|
-
deadlineAt: toDate(details.deadline_at),
|
|
407
|
-
lastRanAt: toDate(details.last_ran_at),
|
|
408
|
-
completedAt: toDate(details.completed_at),
|
|
409
|
-
progress: details.progress || 0,
|
|
410
|
-
progressMessage: details.progress_message || "",
|
|
411
|
-
progressDetails: details.progress_details ?? null,
|
|
412
|
-
status: details.status,
|
|
413
|
-
error: details.error ?? null,
|
|
414
|
-
errorCode: details.error_code ?? null,
|
|
415
|
-
runAttempts: details.run_attempts ?? 0,
|
|
416
|
-
maxRetries: details.max_retries ?? 10
|
|
417
|
-
});
|
|
459
|
+
return storageToClass(details, Job, { includeWorkerId: true });
|
|
418
460
|
}
|
|
419
461
|
buildErrorFromJob(job) {
|
|
420
462
|
return this.buildErrorFromCode(job.error || "Job failed", job.errorCode ?? undefined);
|
|
@@ -736,64 +778,10 @@ class JobQueueWorker {
|
|
|
736
778
|
this.activeJobAbortControllers.delete(jobId);
|
|
737
779
|
}
|
|
738
780
|
storageToClass(details) {
|
|
739
|
-
|
|
740
|
-
if (!date)
|
|
741
|
-
return null;
|
|
742
|
-
const d = new Date(date);
|
|
743
|
-
return isNaN(d.getTime()) ? null : d;
|
|
744
|
-
};
|
|
745
|
-
return new this.jobClass({
|
|
746
|
-
id: details.id,
|
|
747
|
-
jobRunId: details.job_run_id,
|
|
748
|
-
queueName: details.queue,
|
|
749
|
-
fingerprint: details.fingerprint,
|
|
750
|
-
input: details.input,
|
|
751
|
-
output: details.output,
|
|
752
|
-
runAfter: toDate(details.run_after),
|
|
753
|
-
createdAt: toDate(details.created_at),
|
|
754
|
-
deadlineAt: toDate(details.deadline_at),
|
|
755
|
-
lastRanAt: toDate(details.last_ran_at),
|
|
756
|
-
completedAt: toDate(details.completed_at),
|
|
757
|
-
progress: details.progress || 0,
|
|
758
|
-
progressMessage: details.progress_message || "",
|
|
759
|
-
progressDetails: details.progress_details ?? null,
|
|
760
|
-
status: details.status,
|
|
761
|
-
error: details.error ?? null,
|
|
762
|
-
errorCode: details.error_code ?? null,
|
|
763
|
-
runAttempts: details.run_attempts ?? 0,
|
|
764
|
-
maxRetries: details.max_retries ?? 10,
|
|
765
|
-
workerId: details.worker_id ?? null
|
|
766
|
-
});
|
|
781
|
+
return storageToClass(details, this.jobClass);
|
|
767
782
|
}
|
|
768
783
|
classToStorage(job) {
|
|
769
|
-
|
|
770
|
-
if (!date)
|
|
771
|
-
return null;
|
|
772
|
-
return isNaN(date.getTime()) ? null : date.toISOString();
|
|
773
|
-
};
|
|
774
|
-
const now = new Date().toISOString();
|
|
775
|
-
return {
|
|
776
|
-
id: job.id,
|
|
777
|
-
job_run_id: job.jobRunId,
|
|
778
|
-
queue: job.queueName || this.queueName,
|
|
779
|
-
fingerprint: job.fingerprint,
|
|
780
|
-
input: job.input,
|
|
781
|
-
status: job.status,
|
|
782
|
-
output: job.output ?? null,
|
|
783
|
-
error: job.error === null ? null : String(job.error),
|
|
784
|
-
error_code: job.errorCode || null,
|
|
785
|
-
run_attempts: job.runAttempts ?? 0,
|
|
786
|
-
max_retries: job.maxRetries ?? 10,
|
|
787
|
-
run_after: dateToISOString(job.runAfter) ?? now,
|
|
788
|
-
created_at: dateToISOString(job.createdAt) ?? now,
|
|
789
|
-
deadline_at: dateToISOString(job.deadlineAt),
|
|
790
|
-
last_ran_at: dateToISOString(job.lastRanAt),
|
|
791
|
-
completed_at: dateToISOString(job.completedAt),
|
|
792
|
-
progress: job.progress ?? 0,
|
|
793
|
-
progress_message: job.progressMessage ?? "",
|
|
794
|
-
progress_details: job.progressDetails ?? null,
|
|
795
|
-
worker_id: job.workerId ?? null
|
|
796
|
-
};
|
|
784
|
+
return classToStorage(job, this.queueName);
|
|
797
785
|
}
|
|
798
786
|
}
|
|
799
787
|
|
|
@@ -1037,64 +1025,10 @@ class JobQueueServer {
|
|
|
1037
1025
|
}
|
|
1038
1026
|
}
|
|
1039
1027
|
storageToClass(details) {
|
|
1040
|
-
|
|
1041
|
-
if (!date)
|
|
1042
|
-
return null;
|
|
1043
|
-
const d = new Date(date);
|
|
1044
|
-
return isNaN(d.getTime()) ? null : d;
|
|
1045
|
-
};
|
|
1046
|
-
return new this.jobClass({
|
|
1047
|
-
id: details.id,
|
|
1048
|
-
jobRunId: details.job_run_id,
|
|
1049
|
-
queueName: details.queue,
|
|
1050
|
-
fingerprint: details.fingerprint,
|
|
1051
|
-
input: details.input,
|
|
1052
|
-
output: details.output,
|
|
1053
|
-
runAfter: toDate(details.run_after),
|
|
1054
|
-
createdAt: toDate(details.created_at),
|
|
1055
|
-
deadlineAt: toDate(details.deadline_at),
|
|
1056
|
-
lastRanAt: toDate(details.last_ran_at),
|
|
1057
|
-
completedAt: toDate(details.completed_at),
|
|
1058
|
-
progress: details.progress || 0,
|
|
1059
|
-
progressMessage: details.progress_message || "",
|
|
1060
|
-
progressDetails: details.progress_details ?? null,
|
|
1061
|
-
status: details.status,
|
|
1062
|
-
error: details.error ?? null,
|
|
1063
|
-
errorCode: details.error_code ?? null,
|
|
1064
|
-
runAttempts: details.run_attempts ?? 0,
|
|
1065
|
-
maxRetries: details.max_retries ?? 10,
|
|
1066
|
-
workerId: details.worker_id ?? null
|
|
1067
|
-
});
|
|
1028
|
+
return storageToClass(details, this.jobClass);
|
|
1068
1029
|
}
|
|
1069
1030
|
classToStorage(job) {
|
|
1070
|
-
|
|
1071
|
-
if (!date)
|
|
1072
|
-
return null;
|
|
1073
|
-
return isNaN(date.getTime()) ? null : date.toISOString();
|
|
1074
|
-
};
|
|
1075
|
-
const now = new Date().toISOString();
|
|
1076
|
-
return {
|
|
1077
|
-
id: job.id,
|
|
1078
|
-
job_run_id: job.jobRunId,
|
|
1079
|
-
queue: job.queueName || this.queueName,
|
|
1080
|
-
fingerprint: job.fingerprint,
|
|
1081
|
-
input: job.input,
|
|
1082
|
-
status: job.status,
|
|
1083
|
-
output: job.output ?? null,
|
|
1084
|
-
error: job.error === null ? null : String(job.error),
|
|
1085
|
-
error_code: job.errorCode || null,
|
|
1086
|
-
run_attempts: job.runAttempts ?? 0,
|
|
1087
|
-
max_retries: job.maxRetries ?? 10,
|
|
1088
|
-
run_after: dateToISOString(job.runAfter) ?? now,
|
|
1089
|
-
created_at: dateToISOString(job.createdAt) ?? now,
|
|
1090
|
-
deadline_at: dateToISOString(job.deadlineAt),
|
|
1091
|
-
last_ran_at: dateToISOString(job.lastRanAt),
|
|
1092
|
-
completed_at: dateToISOString(job.completedAt),
|
|
1093
|
-
progress: job.progress ?? 0,
|
|
1094
|
-
progress_message: job.progressMessage ?? "",
|
|
1095
|
-
progress_details: job.progressDetails ?? null,
|
|
1096
|
-
worker_id: job.workerId ?? null
|
|
1097
|
-
};
|
|
1031
|
+
return classToStorage(job, this.queueName);
|
|
1098
1032
|
}
|
|
1099
1033
|
getWorkerIds() {
|
|
1100
1034
|
return this.workers.map((worker) => worker.workerId);
|
|
@@ -1377,6 +1311,8 @@ class RateLimiter {
|
|
|
1377
1311
|
}
|
|
1378
1312
|
}
|
|
1379
1313
|
export {
|
|
1314
|
+
storageToClass,
|
|
1315
|
+
classToStorage,
|
|
1380
1316
|
RetryableJobError,
|
|
1381
1317
|
RateLimiter,
|
|
1382
1318
|
PermanentJobError,
|
|
@@ -1400,4 +1336,4 @@ export {
|
|
|
1400
1336
|
AbortSignalJobError
|
|
1401
1337
|
};
|
|
1402
1338
|
|
|
1403
|
-
//# debugId=
|
|
1339
|
+
//# debugId=B30B376D41C1A63E64756E2164756E21
|