@unchainedshop/core-worker 2.14.2 → 3.0.0-alpha3
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/lib/db/WorkQueueCollection.d.ts +1 -1
- package/lib/db/WorkQueueCollection.d.ts.map +1 -1
- package/lib/director/WorkerAdapter.d.ts +13 -1
- package/lib/director/WorkerAdapter.d.ts.map +1 -1
- package/lib/director/WorkerAdapter.js.map +1 -1
- package/lib/director/WorkerDirector.d.ts +24 -1
- package/lib/director/WorkerDirector.d.ts.map +1 -1
- package/lib/director/WorkerDirector.js +2 -2
- package/lib/director/WorkerDirector.js.map +1 -1
- package/lib/director/WorkerEventTypes.js +0 -3
- package/lib/director/WorkerEventTypes.js.map +1 -1
- package/lib/module/configureWorkerModule.d.ts +86 -12
- package/lib/module/configureWorkerModule.d.ts.map +1 -1
- package/lib/module/configureWorkerModule.js +16 -15
- package/lib/module/configureWorkerModule.js.map +1 -1
- package/lib/module/migrations/addMigrations.d.ts +1 -1
- package/lib/module/migrations/addMigrations.d.ts.map +1 -1
- package/lib/schedulers/FailedRescheduler.d.ts +11 -1
- package/lib/schedulers/FailedRescheduler.d.ts.map +1 -1
- package/lib/schedulers/FailedRescheduler.js.map +1 -1
- package/lib/types.d.ts +20 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/worker-index.d.ts +8 -7
- package/lib/worker-index.d.ts.map +1 -1
- package/lib/worker-index.js +8 -7
- package/lib/worker-index.js.map +1 -1
- package/lib/workers/BaseWorker.d.ts +27 -1
- package/lib/workers/BaseWorker.d.ts.map +1 -1
- package/lib/workers/BaseWorker.js.map +1 -1
- package/lib/workers/EventListenerWorker.d.ts +1 -1
- package/lib/workers/EventListenerWorker.d.ts.map +1 -1
- package/lib/workers/EventListenerWorker.js.map +1 -1
- package/lib/workers/IntervalWorker.d.ts +2 -1
- package/lib/workers/IntervalWorker.d.ts.map +1 -1
- package/lib/workers/IntervalWorker.js.map +1 -1
- package/package.json +5 -7
- package/src/db/WorkQueueCollection.ts +1 -1
- package/src/director/WorkerAdapter.ts +15 -1
- package/src/director/WorkerDirector.ts +31 -8
- package/src/director/WorkerEventTypes.ts +0 -4
- package/src/module/configureWorkerModule.ts +115 -28
- package/src/module/migrations/addMigrations.ts +1 -1
- package/src/schedulers/FailedRescheduler.ts +17 -1
- package/src/types.ts +20 -0
- package/src/worker-index.ts +8 -8
- package/src/workers/BaseWorker.ts +28 -1
- package/src/workers/EventListenerWorker.ts +1 -2
- package/src/workers/IntervalWorker.ts +2 -2
- package/lib/db/WorkQueueSchema.d.ts +0 -3
- package/lib/db/WorkQueueSchema.d.ts.map +0 -1
- package/lib/db/WorkQueueSchema.js +0 -20
- package/lib/db/WorkQueueSchema.js.map +0 -1
- package/src/db/WorkQueueSchema.ts +0 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseWorker.js","sourceRoot":"","sources":["../../src/workers/BaseWorker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseWorker.js","sourceRoot":"","sources":["../../src/workers/BaseWorker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAmC/D,MAAM,CAAC,MAAM,UAAU,GAA0B;IAC/C,GAAG,EAAE,4BAA4B;IACjC,KAAK,EAAE,wCAAwC;IAC/C,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,KAAK;IAEf,YAAY,EAAE,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,EAAE,EAAE;QAClC,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,C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,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;oBAC3F,IAAI,QAAQ;wBAAE,OAAO,kBAAkB,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC;oBAC9D,OAAO,IAAI,CAAC;gBACd,CAAC,CAAC;gBAEF,MAAM,kBAAkB,EAAE,CAAC;YAC7B,CAAC;SACF,CAAC;QAEF,aAAa,CAAC,KAAK,EAAE,CAAC;QAEtB,OAAO,aAAa,CAAC;IACvB,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventListenerWorker.d.ts","sourceRoot":"","sources":["../../src/workers/EventListenerWorker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EventListenerWorker.d.ts","sourceRoot":"","sources":["../../src/workers/EventListenerWorker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAatD,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,yBAAyB,CAyClE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventListenerWorker.js","sourceRoot":"","sources":["../../src/workers/EventListenerWorker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EventListenerWorker.js","sourceRoot":"","sources":["../../src/workers/EventListenerWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAW,MAAM,iBAAiB,CAAC;AAEtD,SAAS,QAAQ,CAAkC,IAAO,EAAE,IAAI;IAC9D,IAAI,OAAO,CAAC;IACZ,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE;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AC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntervalWorker.d.ts","sourceRoot":"","sources":["../../src/workers/IntervalWorker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntervalWorker.d.ts","sourceRoot":"","sources":["../../src/workers/IntervalWorker.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIpD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;CACpC;AAMD,eAAO,MAAM,kBAAkB,gBAAiB,cAAc,GAAG,MAAM,WAMtE,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC,oBAAoB,CA+BxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntervalWorker.js","sourceRoot":"","sources":["../../src/workers/IntervalWorker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntervalWorker.js","sourceRoot":"","sources":["../../src/workers/IntervalWorker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,UAAU,EAAW,MAAM,iBAAiB,CAAC;AAGtD,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAQjC,MAAM,eAAe,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CACtC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,kBAAkB,CACjD,CAAC;AAEpB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAAoC,EAAE,EAAE;IACzE,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,IAAI,C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AC,CAAC;gBACL,CAAC,EAAE,aAAa,CAAC,CAAC;YACpB,CAAC;YAED,IAAI;gBACF,aAAa,CAAC,cAAc,CAAC,CAAC;YAChC,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-worker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha3",
|
|
4
4
|
"main": "lib/worker-index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/worker-index.js",
|
|
@@ -32,15 +32,13 @@
|
|
|
32
32
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@breejs/later": "^4.2.0",
|
|
35
|
-
"@unchainedshop/logger": "^
|
|
36
|
-
"@unchainedshop/utils": "^
|
|
37
|
-
"simpl-schema": "^3.4.6"
|
|
35
|
+
"@unchainedshop/logger": "^3.0.0-alpha3",
|
|
36
|
+
"@unchainedshop/utils": "^3.0.0-alpha3"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
|
-
"@types/node": "^
|
|
41
|
-
"@unchainedshop/types": "^2.14.2",
|
|
39
|
+
"@types/node": "^22.5.5",
|
|
42
40
|
"jest": "^29.7.0",
|
|
43
41
|
"ts-jest": "^29.2.5",
|
|
44
|
-
"typescript": "^5.
|
|
42
|
+
"typescript": "^5.6.2"
|
|
45
43
|
}
|
|
46
44
|
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
|
|
2
1
|
import { log, LogLevel } from '@unchainedshop/logger';
|
|
2
|
+
import type { IBaseAdapter } from '@unchainedshop/utils';
|
|
3
|
+
import type { UnchainedCore } from '@unchainedshop/core';
|
|
4
|
+
export interface WorkResult<Result> {
|
|
5
|
+
success: boolean;
|
|
6
|
+
result?: Result;
|
|
7
|
+
error?: any;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type IWorkerAdapter<Input, Output> = IBaseAdapter & {
|
|
11
|
+
type: string;
|
|
12
|
+
external: boolean;
|
|
13
|
+
maxParallelAllocations?: number;
|
|
14
|
+
|
|
15
|
+
doWork: (input: Input, unchainedAPI: UnchainedCore, workId: string) => Promise<WorkResult<Output>>;
|
|
16
|
+
};
|
|
3
17
|
|
|
4
18
|
export const WorkerAdapter: Omit<IWorkerAdapter<any, void>, 'key' | 'label' | 'type' | 'version'> = {
|
|
5
19
|
external: false,
|
|
@@ -1,13 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
WorkScheduleConfiguration,
|
|
5
|
-
} from '@unchainedshop/types/worker.js';
|
|
1
|
+
import type { WorkData, IWorkerAdapter, WorkResult } from '../worker-index.js';
|
|
2
|
+
import type { UnchainedCore } from '@unchainedshop/core';
|
|
3
|
+
|
|
6
4
|
import { log, LogLevel } from '@unchainedshop/logger';
|
|
7
|
-
import { BaseDirector } from '@unchainedshop/utils';
|
|
5
|
+
import { BaseDirector, IBaseDirector } from '@unchainedshop/utils';
|
|
6
|
+
import { Work } from '../types.js';
|
|
8
7
|
|
|
9
8
|
export const DIRECTOR_MARKED_FAILED_ERROR = 'DIRECTOR_MARKED_FAILED';
|
|
10
9
|
|
|
10
|
+
export interface WorkerSchedule {
|
|
11
|
+
schedules: Array<Record<string, any>>;
|
|
12
|
+
exceptions: Array<Record<string, any>>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type WorkScheduleConfiguration = Pick<
|
|
16
|
+
WorkData,
|
|
17
|
+
'timeout' | 'retries' | 'priority' | 'worker' | 'scheduleId'
|
|
18
|
+
> & {
|
|
19
|
+
type: string;
|
|
20
|
+
input?: (workData: Omit<WorkData, 'input'>) => Promise<Record<string, any> | null>;
|
|
21
|
+
schedule: WorkerSchedule;
|
|
22
|
+
scheduleId?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type IWorkerDirector = IBaseDirector<IWorkerAdapter<any, any>> & {
|
|
26
|
+
getActivePluginTypes: (options?: { external?: boolean }) => Array<string>;
|
|
27
|
+
getAdapterByType: (type: string) => IWorkerAdapter<any, any>;
|
|
28
|
+
disableAutoscheduling: (scheduleId: string) => void;
|
|
29
|
+
configureAutoscheduling: (workScheduleConfiguration: WorkScheduleConfiguration) => void;
|
|
30
|
+
getAutoSchedules: () => Array<[string, WorkScheduleConfiguration]>;
|
|
31
|
+
doWork: (work: Work, unchainedAPI: UnchainedCore) => Promise<WorkResult<any>>;
|
|
32
|
+
};
|
|
33
|
+
|
|
11
34
|
const AutoScheduleMap = new Map<string, WorkScheduleConfiguration>();
|
|
12
35
|
|
|
13
36
|
const baseDirector = BaseDirector<IWorkerAdapter<any, any>>('WorkerDirector', {
|
|
@@ -17,7 +40,7 @@ const baseDirector = BaseDirector<IWorkerAdapter<any, any>>('WorkerDirector', {
|
|
|
17
40
|
export const WorkerDirector: IWorkerDirector = {
|
|
18
41
|
...baseDirector,
|
|
19
42
|
|
|
20
|
-
getActivePluginTypes: ({ external } = {}) => {
|
|
43
|
+
getActivePluginTypes: ({ external } = { external: null }) => {
|
|
21
44
|
return WorkerDirector.getAdapters()
|
|
22
45
|
.filter((adapter) => {
|
|
23
46
|
if (external === null || external === undefined) return true;
|
|
@@ -60,7 +83,7 @@ export const WorkerDirector: IWorkerDirector = {
|
|
|
60
83
|
workItemConfiguration,
|
|
61
84
|
);
|
|
62
85
|
log(
|
|
63
|
-
`WorkerDirector -> Configured ${adapter.type} ${adapter.key}@${adapter.version} (${adapter.label}) for Autorun at ${workItemConfiguration.schedule}`,
|
|
86
|
+
`WorkerDirector -> Configured ${adapter.type} ${adapter.key}@${adapter.version} (${adapter.label}) for Autorun at ${JSON.stringify(workItemConfiguration.schedule?.schedules)}`,
|
|
64
87
|
);
|
|
65
88
|
},
|
|
66
89
|
|
|
@@ -5,7 +5,3 @@ export enum WorkerEventTypes {
|
|
|
5
5
|
DELETED = 'WORK_DELETED',
|
|
6
6
|
RESCHEDULED = 'WORK_RESCHEDULED',
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
// The difference between `done` and `finished` is, that work is `done` after
|
|
10
|
-
// it was computed (no DB write, could be external) and `finished` after
|
|
11
|
-
// the changes are written to the DB
|
|
@@ -1,27 +1,99 @@
|
|
|
1
|
+
import type { WorkData, WorkResult } from '../worker-index.js';
|
|
2
|
+
import type { ModuleInput, UnchainedCore } from '@unchainedshop/core';
|
|
3
|
+
|
|
1
4
|
import os from 'os';
|
|
2
|
-
import { ModuleInput, ModuleMutations } from '@unchainedshop/types/core.js';
|
|
3
|
-
import { Work, WorkerModule, WorkerReport, WorkerSettingsOptions } from '@unchainedshop/types/worker.js';
|
|
4
5
|
import { createLogger } from '@unchainedshop/logger';
|
|
5
6
|
import {
|
|
6
7
|
generateDbFilterById,
|
|
7
|
-
generateDbMutations,
|
|
8
8
|
buildSortOptions,
|
|
9
9
|
mongodb,
|
|
10
|
+
generateDbObjectId,
|
|
10
11
|
} from '@unchainedshop/mongodb';
|
|
11
|
-
import { SortDirection } from '@unchainedshop/types/api.js';
|
|
12
12
|
import { emit, registerEvents } from '@unchainedshop/events';
|
|
13
|
-
import { buildObfuscatedFieldsFilter } from '@unchainedshop/utils';
|
|
13
|
+
import { buildObfuscatedFieldsFilter, SortDirection, SortOption } from '@unchainedshop/utils';
|
|
14
14
|
import { WorkQueueCollection } from '../db/WorkQueueCollection.js';
|
|
15
|
-
import { WorkQueueSchema } from '../db/WorkQueueSchema.js';
|
|
16
15
|
import { DIRECTOR_MARKED_FAILED_ERROR, WorkerDirector } from '../director/WorkerDirector.js';
|
|
17
16
|
import { WorkerEventTypes } from '../director/WorkerEventTypes.js';
|
|
18
17
|
import { WorkStatus } from '../director/WorkStatus.js';
|
|
18
|
+
import { Work } from '../types.js';
|
|
19
19
|
import addMigrations from './migrations/addMigrations.js';
|
|
20
20
|
|
|
21
21
|
const { UNCHAINED_WORKER_ID = os.hostname() } = process.env;
|
|
22
22
|
|
|
23
23
|
const logger = createLogger('unchained:core-worker');
|
|
24
24
|
|
|
25
|
+
export interface WorkerSettingsOptions {
|
|
26
|
+
blacklistedVariables?: string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type WorkerReport = {
|
|
30
|
+
type: string;
|
|
31
|
+
newCount: number;
|
|
32
|
+
errorCount: number;
|
|
33
|
+
successCount: number;
|
|
34
|
+
startCount: number;
|
|
35
|
+
deleteCount: number;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type WorkQueueQuery = {
|
|
39
|
+
created?: { end?: Date; start?: Date };
|
|
40
|
+
types?: Array<string>;
|
|
41
|
+
status: Array<WorkStatus>;
|
|
42
|
+
queryString?: string;
|
|
43
|
+
scheduled?: { end?: Date; start?: Date };
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type WorkerModule = {
|
|
47
|
+
activeWorkTypes: () => Promise<Array<string>>;
|
|
48
|
+
findWork: (query: { workId?: string; originalWorkId?: string }) => Promise<Work>;
|
|
49
|
+
findWorkQueue: (
|
|
50
|
+
query: WorkQueueQuery & {
|
|
51
|
+
sort?: Array<SortOption>;
|
|
52
|
+
limit?: number;
|
|
53
|
+
skip?: number;
|
|
54
|
+
},
|
|
55
|
+
) => Promise<Array<Work>>;
|
|
56
|
+
count: (query: WorkQueueQuery) => Promise<number>;
|
|
57
|
+
workExists: (query: { workId?: string; originalWorkId?: string }) => Promise<boolean>;
|
|
58
|
+
|
|
59
|
+
// Transformations
|
|
60
|
+
status: (work: Work) => WorkStatus;
|
|
61
|
+
|
|
62
|
+
type: (work: Work) => string;
|
|
63
|
+
|
|
64
|
+
// Mutations
|
|
65
|
+
addWork: (data: WorkData) => Promise<Work>;
|
|
66
|
+
|
|
67
|
+
allocateWork: (doc: { types: Array<string>; worker: string }) => Promise<Work>;
|
|
68
|
+
|
|
69
|
+
processNextWork: (unchainedAPI: UnchainedCore, workerId?: string) => Promise<Work>;
|
|
70
|
+
|
|
71
|
+
rescheduleWork: (work: Work, scheduled: Date, unchainedAPI: UnchainedCore) => Promise<Work>;
|
|
72
|
+
|
|
73
|
+
ensureOneWork: (work: WorkData) => Promise<Work>;
|
|
74
|
+
|
|
75
|
+
ensureNoWork: (work: { priority: number; type: string; scheduleId: string }) => Promise<void>;
|
|
76
|
+
|
|
77
|
+
finishWork: (
|
|
78
|
+
_id: string,
|
|
79
|
+
data: WorkResult<any> & {
|
|
80
|
+
finished?: Date;
|
|
81
|
+
started?: Date;
|
|
82
|
+
worker?: string;
|
|
83
|
+
},
|
|
84
|
+
) => Promise<Work | null>;
|
|
85
|
+
|
|
86
|
+
deleteWork: (_id: string) => Promise<Work | null>;
|
|
87
|
+
|
|
88
|
+
markOldWorkAsFailed: (params: {
|
|
89
|
+
types: Array<string>;
|
|
90
|
+
worker: string;
|
|
91
|
+
referenceDate: Date;
|
|
92
|
+
}) => Promise<Array<Work>>;
|
|
93
|
+
|
|
94
|
+
getReport: (params?: { types?: string[]; from?: Date; to?: Date }) => Promise<WorkerReport[]>;
|
|
95
|
+
};
|
|
96
|
+
|
|
25
97
|
const WORK_STATUS_FILTER_MAP = {
|
|
26
98
|
[WorkStatus.DELETED]: { deleted: { $exists: true } },
|
|
27
99
|
[WorkStatus.NEW]: {
|
|
@@ -117,6 +189,7 @@ const defaultSort: Array<{ key: string; value: SortDirection }> = [
|
|
|
117
189
|
{ key: 'originalWorkId', value: SortDirection.ASC },
|
|
118
190
|
{ key: 'created', value: SortDirection.ASC },
|
|
119
191
|
];
|
|
192
|
+
|
|
120
193
|
const normalizeWorkQueueAggregateResult = (data = []): WorkerReport[] => {
|
|
121
194
|
const statusToFieldMap = {
|
|
122
195
|
NEW: 'newCount',
|
|
@@ -145,6 +218,7 @@ const normalizeWorkQueueAggregateResult = (data = []): WorkerReport[] => {
|
|
|
145
218
|
return workStatistics;
|
|
146
219
|
}) as unknown as WorkerReport[];
|
|
147
220
|
};
|
|
221
|
+
|
|
148
222
|
export const configureWorkerModule = async ({
|
|
149
223
|
db,
|
|
150
224
|
migrationRepository,
|
|
@@ -158,8 +232,6 @@ export const configureWorkerModule = async ({
|
|
|
158
232
|
|
|
159
233
|
const removePrivateFields = buildObfuscatedFieldsFilter(options?.blacklistedVariables);
|
|
160
234
|
|
|
161
|
-
const mutations = generateDbMutations<Work>(WorkQueue, WorkQueueSchema) as ModuleMutations<Work>;
|
|
162
|
-
|
|
163
235
|
const allocateWork: WorkerModule['allocateWork'] = async ({ types, worker = UNCHAINED_WORKER_ID }) => {
|
|
164
236
|
// Find a work item that is scheduled for now and is not started.
|
|
165
237
|
// Also:
|
|
@@ -203,18 +275,21 @@ export const configureWorkerModule = async ({
|
|
|
203
275
|
|
|
204
276
|
if (!workBeforeUpdate) return null;
|
|
205
277
|
|
|
206
|
-
await
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
278
|
+
const work = await WorkQueue.findOneAndUpdate(
|
|
279
|
+
generateDbFilterById(workId),
|
|
280
|
+
{
|
|
281
|
+
$set: {
|
|
282
|
+
updated: new Date(),
|
|
283
|
+
finished,
|
|
284
|
+
success,
|
|
285
|
+
error,
|
|
286
|
+
result,
|
|
287
|
+
...(!workBeforeUpdate.started ? { started } : {}),
|
|
288
|
+
worker,
|
|
289
|
+
},
|
|
214
290
|
},
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const work = await WorkQueue.findOne(generateDbFilterById(workId), {});
|
|
291
|
+
{ returnDocument: 'after' },
|
|
292
|
+
);
|
|
218
293
|
|
|
219
294
|
const duration = new Date(work.finished).getTime() - new Date(work.started).getTime();
|
|
220
295
|
if (work.success) {
|
|
@@ -382,14 +457,15 @@ export const configureWorkerModule = async ({
|
|
|
382
457
|
}
|
|
383
458
|
|
|
384
459
|
const created = new Date();
|
|
385
|
-
const workId = await
|
|
460
|
+
const { insertedId: workId } = await WorkQueue.insertOne({
|
|
461
|
+
_id: generateDbObjectId(),
|
|
462
|
+
created,
|
|
386
463
|
type,
|
|
387
464
|
input,
|
|
388
465
|
priority,
|
|
389
466
|
scheduled: scheduled || created,
|
|
390
467
|
originalWorkId,
|
|
391
468
|
retries,
|
|
392
|
-
created,
|
|
393
469
|
worker,
|
|
394
470
|
});
|
|
395
471
|
|
|
@@ -404,13 +480,17 @@ export const configureWorkerModule = async ({
|
|
|
404
480
|
},
|
|
405
481
|
|
|
406
482
|
rescheduleWork: async (currentWork, scheduled) => {
|
|
407
|
-
await
|
|
408
|
-
|
|
409
|
-
|
|
483
|
+
const work = await WorkQueue.findOneAndUpdate(
|
|
484
|
+
generateDbFilterById(currentWork._id),
|
|
485
|
+
{
|
|
486
|
+
$set: {
|
|
487
|
+
updated: new Date(),
|
|
488
|
+
scheduled,
|
|
489
|
+
},
|
|
410
490
|
},
|
|
411
|
-
|
|
491
|
+
{ returnDocument: 'after' },
|
|
492
|
+
);
|
|
412
493
|
|
|
413
|
-
const work = await WorkQueue.findOne(generateDbFilterById(currentWork._id), {});
|
|
414
494
|
emit(WorkerEventTypes.RESCHEDULED, {
|
|
415
495
|
work: removePrivateFields(work),
|
|
416
496
|
oldScheduled: currentWork.scheduled,
|
|
@@ -520,9 +600,16 @@ export const configureWorkerModule = async ({
|
|
|
520
600
|
);
|
|
521
601
|
if (!workBeforeRemoval) return null;
|
|
522
602
|
|
|
523
|
-
await
|
|
603
|
+
const work = await WorkQueue.findOneAndUpdate(
|
|
604
|
+
generateDbFilterById(workId),
|
|
605
|
+
{
|
|
606
|
+
$set: {
|
|
607
|
+
deleted: new Date(),
|
|
608
|
+
},
|
|
609
|
+
},
|
|
610
|
+
{ returnDocument: 'after' },
|
|
611
|
+
);
|
|
524
612
|
|
|
525
|
-
const work = await WorkQueue.findOne(generateDbFilterById(workId), {});
|
|
526
613
|
emit(WorkerEventTypes.DELETED, removePrivateFields(work));
|
|
527
614
|
|
|
528
615
|
return work;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Migration, MigrationRepository } from '@unchainedshop/
|
|
1
|
+
import { Migration, MigrationRepository } from '@unchainedshop/core';
|
|
2
2
|
import { WorkQueueCollection } from '../../db/WorkQueueCollection.js';
|
|
3
3
|
|
|
4
4
|
export default function addMigrations(repository: MigrationRepository<Migration>) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { IScheduler, Work, WorkData } from '@unchainedshop/types/worker.js';
|
|
2
1
|
import { log } from '@unchainedshop/logger';
|
|
3
2
|
import { subscribe } from '@unchainedshop/events';
|
|
4
3
|
import { WorkerEventTypes } from '../director/WorkerEventTypes.js';
|
|
4
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
5
|
+
import { WorkData } from '../worker-index.js';
|
|
6
|
+
import { Work } from '../types.js';
|
|
5
7
|
|
|
6
8
|
export interface FailedReschedulerParams {
|
|
7
9
|
retryInput?: (
|
|
@@ -10,6 +12,20 @@ export interface FailedReschedulerParams {
|
|
|
10
12
|
) => Promise<Record<string, any> | null>;
|
|
11
13
|
}
|
|
12
14
|
|
|
15
|
+
export type IScheduler<P> = {
|
|
16
|
+
key: string;
|
|
17
|
+
label: string;
|
|
18
|
+
version: string;
|
|
19
|
+
|
|
20
|
+
actions: (
|
|
21
|
+
params: P,
|
|
22
|
+
unchainedAPI: UnchainedCore,
|
|
23
|
+
) => {
|
|
24
|
+
start: () => void;
|
|
25
|
+
stop: () => void;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
13
29
|
export const FailedRescheduler: IScheduler<FailedReschedulerParams> = {
|
|
14
30
|
key: 'shop.unchained.scheduler.failed',
|
|
15
31
|
label: 'Reschedule failed works',
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TimestampFields } from '@unchainedshop/mongodb';
|
|
2
|
+
|
|
3
|
+
export type Work = {
|
|
4
|
+
_id?: string;
|
|
5
|
+
priority: number;
|
|
6
|
+
retries: number;
|
|
7
|
+
scheduled: Date;
|
|
8
|
+
type: string;
|
|
9
|
+
input: Record<string, any>;
|
|
10
|
+
error?: any;
|
|
11
|
+
finished?: Date;
|
|
12
|
+
originalWorkId?: string;
|
|
13
|
+
result?: any;
|
|
14
|
+
started?: Date;
|
|
15
|
+
success?: boolean;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
worker?: string;
|
|
18
|
+
autoscheduled?: boolean;
|
|
19
|
+
scheduleId?: string;
|
|
20
|
+
} & TimestampFields;
|
package/src/worker-index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './types.js';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export * from './module/configureWorkerModule.js';
|
|
4
|
+
export * from './director/WorkerDirector.js';
|
|
5
|
+
export * from './director/WorkerAdapter.js';
|
|
5
6
|
export { WorkStatus } from './director/WorkStatus.js';
|
|
6
7
|
export { WorkerEventTypes } from './director/WorkerEventTypes.js';
|
|
7
8
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export { IntervalWorker } from './workers/IntervalWorker.js';
|
|
9
|
+
export * from './schedulers/FailedRescheduler.js';
|
|
10
|
+
export * from './workers/BaseWorker.js';
|
|
11
|
+
export * from './workers/EventListenerWorker.js';
|
|
12
|
+
export * from './workers/IntervalWorker.js';
|
|
@@ -1,7 +1,34 @@
|
|
|
1
|
-
import { IWorker, WorkData } from '@unchainedshop/types/worker.js';
|
|
2
1
|
import later from '@breejs/later';
|
|
3
2
|
import { log } from '@unchainedshop/logger';
|
|
4
3
|
import { WorkerDirector } from '../director/WorkerDirector.js';
|
|
4
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
5
|
+
import { Work } from '../types.js';
|
|
6
|
+
|
|
7
|
+
export type WorkData = Pick<
|
|
8
|
+
Partial<Work>,
|
|
9
|
+
'input' | 'originalWorkId' | 'priority' | 'retries' | 'timeout' | 'scheduled' | 'worker' | 'scheduleId'
|
|
10
|
+
> & { type: string };
|
|
11
|
+
|
|
12
|
+
export type IWorker<P extends { workerId?: string }> = {
|
|
13
|
+
key: string;
|
|
14
|
+
label: string;
|
|
15
|
+
version: string;
|
|
16
|
+
type: string;
|
|
17
|
+
external: boolean;
|
|
18
|
+
|
|
19
|
+
getFloorDate: (date?: Date) => Date;
|
|
20
|
+
|
|
21
|
+
actions: (
|
|
22
|
+
params: P,
|
|
23
|
+
unchainedAPI: UnchainedCore,
|
|
24
|
+
) => {
|
|
25
|
+
autorescheduleTypes: (options: { referenceDate: Date }) => Promise<Array<Work | null>>;
|
|
26
|
+
process: (options: { maxWorkItemCount?: number; referenceDate?: Date }) => Promise<void>;
|
|
27
|
+
reset: () => Promise<void>;
|
|
28
|
+
start: () => void;
|
|
29
|
+
stop: () => void;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
5
32
|
|
|
6
33
|
interface WorkerParams {
|
|
7
34
|
workerId?: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { IWorker } from '@unchainedshop/types/worker.js';
|
|
2
1
|
import { subscribe } from '@unchainedshop/events';
|
|
3
2
|
import { WorkerEventTypes } from '../director/WorkerEventTypes.js';
|
|
4
|
-
import { BaseWorker } from './BaseWorker.js';
|
|
3
|
+
import { BaseWorker, IWorker } from './BaseWorker.js';
|
|
5
4
|
|
|
6
5
|
function debounce<T extends (...args: any) => any>(func: T, wait) {
|
|
7
6
|
let timeout;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IWorker, WorkerSchedule } from '@unchainedshop/types/worker.js';
|
|
2
1
|
import later from '@breejs/later';
|
|
3
|
-
import { BaseWorker } from './BaseWorker.js';
|
|
2
|
+
import { BaseWorker, IWorker } from './BaseWorker.js';
|
|
3
|
+
import { WorkerSchedule } from '../worker-index.js';
|
|
4
4
|
|
|
5
5
|
const { NODE_ENV } = process.env;
|
|
6
6
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorkQueueSchema.d.ts","sourceRoot":"","sources":["../../src/db/WorkQueueSchema.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,eAAe,cAmB3B,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Schemas } from '@unchainedshop/utils';
|
|
2
|
-
import SimpleSchema from 'simpl-schema';
|
|
3
|
-
export const WorkQueueSchema = new SimpleSchema({
|
|
4
|
-
finished: Date,
|
|
5
|
-
originalWorkId: { type: String },
|
|
6
|
-
priority: { type: Number, required: true },
|
|
7
|
-
retries: { type: Number, required: true },
|
|
8
|
-
scheduled: { type: Date, required: true },
|
|
9
|
-
started: Date,
|
|
10
|
-
success: Boolean,
|
|
11
|
-
timeout: Number,
|
|
12
|
-
type: { type: String, required: true },
|
|
13
|
-
worker: String,
|
|
14
|
-
// Worker data
|
|
15
|
-
input: { type: Object, blackbox: true },
|
|
16
|
-
result: { type: Object, blackbox: true },
|
|
17
|
-
error: { type: Object, blackbox: true },
|
|
18
|
-
...Schemas.timestampFields,
|
|
19
|
-
}, { requiredByDefault: false });
|
|
20
|
-
//# sourceMappingURL=WorkQueueSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorkQueueSchema.js","sourceRoot":"","sources":["../../src/db/WorkQueueSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,YAAY,CAC7C;IACE,QAAQ,EAAE,IAAI;IACd,cAAc,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAChC,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC1C,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACzC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACzC,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,MAAM;IACf,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACtC,MAAM,EAAE,MAAM;IACd,cAAc;IACd,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACvC,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACxC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACvC,GAAG,OAAO,CAAC,eAAe;CAC3B,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Schemas } from '@unchainedshop/utils';
|
|
2
|
-
import SimpleSchema from 'simpl-schema';
|
|
3
|
-
|
|
4
|
-
export const WorkQueueSchema = new SimpleSchema(
|
|
5
|
-
{
|
|
6
|
-
finished: Date,
|
|
7
|
-
originalWorkId: { type: String },
|
|
8
|
-
priority: { type: Number, required: true },
|
|
9
|
-
retries: { type: Number, required: true },
|
|
10
|
-
scheduled: { type: Date, required: true },
|
|
11
|
-
started: Date,
|
|
12
|
-
success: Boolean,
|
|
13
|
-
timeout: Number,
|
|
14
|
-
type: { type: String, required: true },
|
|
15
|
-
worker: String,
|
|
16
|
-
// Worker data
|
|
17
|
-
input: { type: Object, blackbox: true },
|
|
18
|
-
result: { type: Object, blackbox: true },
|
|
19
|
-
error: { type: Object, blackbox: true },
|
|
20
|
-
...Schemas.timestampFields,
|
|
21
|
-
},
|
|
22
|
-
{ requiredByDefault: false },
|
|
23
|
-
);
|