@spinajs/tasks 2.0.554 → 2.0.555
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/cjs/decorators.d.ts +26 -2
- package/lib/cjs/decorators.d.ts.map +1 -1
- package/lib/cjs/decorators.js +119 -67
- package/lib/cjs/decorators.js.map +1 -1
- package/lib/mjs/decorators.d.ts +26 -2
- package/lib/mjs/decorators.d.ts.map +1 -1
- package/lib/mjs/decorators.js +117 -67
- package/lib/mjs/decorators.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +7 -7
package/lib/cjs/decorators.d.ts
CHANGED
|
@@ -11,14 +11,38 @@ export interface TaskOptions {
|
|
|
11
11
|
lockTtl: number;
|
|
12
12
|
}
|
|
13
13
|
export declare const DEFAULT_TASK_OPTIONS: TaskOptions;
|
|
14
|
+
export interface TaskDeclaration {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
options: TaskOptions;
|
|
18
|
+
/** The class that declares the method (the constructor itself for a static method). */
|
|
19
|
+
target: Function;
|
|
20
|
+
isStatic: boolean;
|
|
21
|
+
propertyKey: string | symbol;
|
|
22
|
+
/** The undecorated method. */
|
|
23
|
+
method: (...args: any[]) => unknown;
|
|
24
|
+
}
|
|
25
|
+
export interface RunTaskOptions {
|
|
26
|
+
/** false: skip the task mutex, its heartbeat and the in-process guard (the caller holds a lock of its own). */
|
|
27
|
+
lock: boolean;
|
|
28
|
+
/** true: rethrow the task's error after history is written, instead of resolving with `{ error: true }`. */
|
|
29
|
+
rethrow: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function getTaskDeclarations(name?: string): TaskDeclaration[];
|
|
32
|
+
/**
|
|
33
|
+
* Runs a task method with the `@Task` bookkeeping: `__tasks` state, a `__task_history` row and
|
|
34
|
+
* TaskSuccess / TaskFailed. The decorator calls it with `{ lock: true, rethrow: false }`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function runTask(decl: TaskDeclaration, thisArg: unknown, args: unknown[], opts: RunTaskOptions): Promise<unknown>;
|
|
14
37
|
/**
|
|
15
38
|
* Marks a method as a task: records runs in `__tasks` / `__task_history`, emits
|
|
16
39
|
* TaskSuccess / TaskFailed and, unless `taskStacking` is set, lets only one run
|
|
17
|
-
* happen at a time across all processes sharing the database.
|
|
40
|
+
* happen at a time across all processes sharing the database. The declaration is
|
|
41
|
+
* also recorded, so `@spinajs/scheduler` can schedule the method by task name.
|
|
18
42
|
*
|
|
19
43
|
* @param taskName - unique task name
|
|
20
44
|
* @param description - short description
|
|
21
45
|
* @param opts - see {@link TaskOptions}, defaults to {@link DEFAULT_TASK_OPTIONS}
|
|
22
46
|
*/
|
|
23
|
-
export declare function Task(taskName: string, description: string, opts?: Partial<TaskOptions>): (
|
|
47
|
+
export declare function Task(taskName: string, description: string, opts?: Partial<TaskOptions>): (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
|
|
24
48
|
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,oBAAoB,EAAE,WAGlC,CAAC;AAqDF
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,oBAAoB,EAAE,WAGlC,CAAC;AAqDF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,WAAW,CAAC;IACrB,uFAAuF;IACvF,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,8BAA8B;IAC9B,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAC7B,+GAA+G;IAC/G,IAAI,EAAE,OAAO,CAAC;IACd,4GAA4G;IAC5G,OAAO,EAAE,OAAO,CAAC;CAClB;AAID,wBAAgB,mBAAmB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,eAAe,EAAE,CAKpE;AAQD;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,OAAO,EAAE,EACf,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,OAAO,CAAC,CAsFlB;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,YAK5D,GAAG,eAAe,MAAM,GAAG,MAAM,cAAc,kBAAkB,UAiB3F"}
|
package/lib/cjs/decorators.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_TASK_OPTIONS = exports.TASK_COMMAND = void 0;
|
|
4
|
+
exports.getTaskDeclarations = getTaskDeclarations;
|
|
5
|
+
exports.runTask = runTask;
|
|
4
6
|
exports.Task = Task;
|
|
5
7
|
const threading_1 = require("@spinajs/threading");
|
|
6
8
|
const util_1 = require("@spinajs/util");
|
|
@@ -57,10 +59,112 @@ async function lockTask(name, opts, log) {
|
|
|
57
59
|
await (0, threading_1.mutex_release)({ Name: mutexName });
|
|
58
60
|
};
|
|
59
61
|
}
|
|
62
|
+
const declarations = new Map();
|
|
63
|
+
function getTaskDeclarations(name) {
|
|
64
|
+
if (name !== undefined) {
|
|
65
|
+
return [...(declarations.get(name) ?? [])];
|
|
66
|
+
}
|
|
67
|
+
return [...declarations.values()].flat();
|
|
68
|
+
}
|
|
69
|
+
function errorMessage(err) {
|
|
70
|
+
return err?.message ?? String(err);
|
|
71
|
+
}
|
|
72
|
+
const NO_LOCK = () => Promise.resolve();
|
|
73
|
+
/**
|
|
74
|
+
* Runs a task method with the `@Task` bookkeeping: `__tasks` state, a `__task_history` row and
|
|
75
|
+
* TaskSuccess / TaskFailed. The decorator calls it with `{ lock: true, rethrow: false }`.
|
|
76
|
+
*/
|
|
77
|
+
async function runTask(decl, thisArg, args, opts) {
|
|
78
|
+
const log = di_1.DI.resolve('__log__', ['TASKS']);
|
|
79
|
+
log.info(`Executing task ${decl.name} ...`);
|
|
80
|
+
let task;
|
|
81
|
+
let unlock;
|
|
82
|
+
try {
|
|
83
|
+
task = await __task_js_1.__task.getOrCreate(null, {
|
|
84
|
+
Name: decl.name,
|
|
85
|
+
Description: decl.description,
|
|
86
|
+
State: 'stopped',
|
|
87
|
+
});
|
|
88
|
+
const lock = opts.lock ? await lockTask(decl.name, decl.options, log) : NO_LOCK;
|
|
89
|
+
if (!lock) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
unlock = lock;
|
|
93
|
+
try {
|
|
94
|
+
task.State = 'running';
|
|
95
|
+
task.LastRunAt = luxon_1.DateTime.now();
|
|
96
|
+
await task.update();
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
await unlock();
|
|
100
|
+
throw err;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
log.error(err, `Cannot start task ${decl.name}`);
|
|
105
|
+
throw err;
|
|
106
|
+
}
|
|
107
|
+
let taskResult = null;
|
|
108
|
+
let failure = null;
|
|
109
|
+
const start = luxon_1.DateTime.now();
|
|
110
|
+
try {
|
|
111
|
+
try {
|
|
112
|
+
taskResult = await decl.method.apply(thisArg, args);
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
failure = { error: err };
|
|
116
|
+
log.error(err, `Cannot execute task ${decl.name}`);
|
|
117
|
+
taskResult = {
|
|
118
|
+
error: true,
|
|
119
|
+
message: errorMessage(err),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
// An emit failure (queue outage) is logged only: it must not turn a run whose side effects
|
|
123
|
+
// already happened into a failure that a caller would retry.
|
|
124
|
+
try {
|
|
125
|
+
if (failure) {
|
|
126
|
+
await TaskFailed_js_1.TaskFailed.emit({
|
|
127
|
+
TaskName: decl.name,
|
|
128
|
+
Reason: errorMessage(failure.error),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
await TaskSuccess_js_1.TaskSuccess.emit({
|
|
133
|
+
TaskName: decl.name,
|
|
134
|
+
});
|
|
135
|
+
log.success(`Task ${decl.name} executed !`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (emitErr) {
|
|
139
|
+
log.error(emitErr, `Cannot emit ${failure ? 'TaskFailed' : 'TaskSuccess'} for ${decl.name}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
try {
|
|
144
|
+
await unlock();
|
|
145
|
+
await task.update({
|
|
146
|
+
State: 'stopped',
|
|
147
|
+
});
|
|
148
|
+
await __task_history_js_1.__task_history.insert({
|
|
149
|
+
TaskId: task.Id,
|
|
150
|
+
Result: taskResult,
|
|
151
|
+
Duration: luxon_1.DateTime.now().diff(start).milliseconds,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
log.error(err, `Cannot finalize task`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (failure && opts.rethrow) {
|
|
159
|
+
throw failure.error;
|
|
160
|
+
}
|
|
161
|
+
return taskResult;
|
|
162
|
+
}
|
|
60
163
|
/**
|
|
61
164
|
* Marks a method as a task: records runs in `__tasks` / `__task_history`, emits
|
|
62
165
|
* TaskSuccess / TaskFailed and, unless `taskStacking` is set, lets only one run
|
|
63
|
-
* happen at a time across all processes sharing the database.
|
|
166
|
+
* happen at a time across all processes sharing the database. The declaration is
|
|
167
|
+
* also recorded, so `@spinajs/scheduler` can schedule the method by task name.
|
|
64
168
|
*
|
|
65
169
|
* @param taskName - unique task name
|
|
66
170
|
* @param description - short description
|
|
@@ -70,72 +174,20 @@ function Task(taskName, description, opts) {
|
|
|
70
174
|
const _name = (0, util_1._check_arg)((0, util_1._trim)(), (0, util_1._non_empty)())(taskName, 'Task name is empty');
|
|
71
175
|
const _description = (0, util_1._check_arg)((0, util_1._trim)(), (0, util_1._non_empty)())(description, 'Task description is empty');
|
|
72
176
|
const _opts = { ...exports.DEFAULT_TASK_OPTIONS, ...opts };
|
|
73
|
-
return function (
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
task.State = 'running';
|
|
90
|
-
task.LastRunAt = luxon_1.DateTime.now();
|
|
91
|
-
await task.update();
|
|
92
|
-
}
|
|
93
|
-
catch (err) {
|
|
94
|
-
await unlock();
|
|
95
|
-
throw err;
|
|
96
|
-
}
|
|
97
|
-
let taskResult = null;
|
|
98
|
-
const start = luxon_1.DateTime.now();
|
|
99
|
-
try {
|
|
100
|
-
taskResult = await oldFunction.apply(this, args);
|
|
101
|
-
await TaskSuccess_js_1.TaskSuccess.emit({
|
|
102
|
-
TaskName: taskName,
|
|
103
|
-
});
|
|
104
|
-
log.success(`Task ${taskName} executed !`);
|
|
105
|
-
}
|
|
106
|
-
catch (err) {
|
|
107
|
-
log.error(err, `Cannot execute task ${taskName}`);
|
|
108
|
-
taskResult = {
|
|
109
|
-
error: true,
|
|
110
|
-
message: err.Message,
|
|
111
|
-
};
|
|
112
|
-
await TaskFailed_js_1.TaskFailed.emit({
|
|
113
|
-
TaskName: taskName,
|
|
114
|
-
Reason: err.Message,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
finally {
|
|
118
|
-
try {
|
|
119
|
-
await unlock();
|
|
120
|
-
await task.update({
|
|
121
|
-
State: 'stopped',
|
|
122
|
-
});
|
|
123
|
-
await __task_history_js_1.__task_history.insert({
|
|
124
|
-
TaskId: task.Id,
|
|
125
|
-
Result: taskResult,
|
|
126
|
-
Duration: luxon_1.DateTime.now().diff(start).milliseconds,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
catch (err) {
|
|
130
|
-
log.error(err, `Cannot finalize task`);
|
|
131
|
-
}
|
|
132
|
-
return taskResult;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (err) {
|
|
136
|
-
log.error(err, `Cannot start task ${taskName}`);
|
|
137
|
-
throw err;
|
|
138
|
-
}
|
|
177
|
+
return function (target, propertyKey, descriptor) {
|
|
178
|
+
const isStatic = typeof target === 'function';
|
|
179
|
+
const decl = {
|
|
180
|
+
name: _name,
|
|
181
|
+
description: _description,
|
|
182
|
+
options: _opts,
|
|
183
|
+
target: isStatic ? target : target.constructor,
|
|
184
|
+
isStatic,
|
|
185
|
+
propertyKey,
|
|
186
|
+
method: descriptor.value,
|
|
187
|
+
};
|
|
188
|
+
declarations.set(_name, [...(declarations.get(_name) ?? []), decl]);
|
|
189
|
+
descriptor.value = function (...args) {
|
|
190
|
+
return runTask(decl, this, args, { lock: true, rethrow: false });
|
|
139
191
|
};
|
|
140
192
|
};
|
|
141
193
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA+E;AAC/E,wCAA8D;AAC9D,oCAAiC;AACjC,kDAA4C;AAC5C,iCAAiC;AACjC,kEAA4D;AAE5D,4DAAsD;AACtD,0DAAoD;AAEvC,QAAA,YAAY,GAAG,cAAc,CAAC;AAe9B,QAAA,oBAAoB,GAAgB;IAC/C,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,KAAK;CACf,CAAC;AAIF,4EAA4E;AAC5E,8EAA8E;AAC9E,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;AAE3C,KAAK,UAAU,QAAQ,CAAC,IAAY,EAAE,IAAiB,EAAE,GAAQ;IAC/D,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,OAAO,KAAK,IAAI,EAAE,GAAE,CAAC,CAAC;IACxB,CAAC;IAED,IAAI,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,qCAAqC,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,SAAS,GAAG,QAAQ,IAAI,EAAE,CAAC;IAEjC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,IAAA,yBAAa,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC9B,GAAG,CAAC,IAAI,CAAC,iCAAiC,IAAI,oBAAo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AAE,CAAC;IAEhE,OAAO,UAAU,MAAW,EAAE,WAA4B,EAAE,UAA8B;QACxF,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,UAAU,CAAC;QAC9C,MAAM,IAAI,GAAoB;YAC5B,IAAI,EAAE,KAAK;YACX,WAAW,EAAE,YAAY;YACzB,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW;YAC9C,QAAQ;YACR,WAAW;YACX,MAAM,EAAE,UAAU,CAAC,KAAK;SACzB,CAAC;QACF,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QAEpE,UAAU,CAAC,KAAK,GAAG,UAAU,GAAG,IAAW;YACzC,OAAO,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACnE,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/mjs/decorators.d.ts
CHANGED
|
@@ -11,14 +11,38 @@ export interface TaskOptions {
|
|
|
11
11
|
lockTtl: number;
|
|
12
12
|
}
|
|
13
13
|
export declare const DEFAULT_TASK_OPTIONS: TaskOptions;
|
|
14
|
+
export interface TaskDeclaration {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
options: TaskOptions;
|
|
18
|
+
/** The class that declares the method (the constructor itself for a static method). */
|
|
19
|
+
target: Function;
|
|
20
|
+
isStatic: boolean;
|
|
21
|
+
propertyKey: string | symbol;
|
|
22
|
+
/** The undecorated method. */
|
|
23
|
+
method: (...args: any[]) => unknown;
|
|
24
|
+
}
|
|
25
|
+
export interface RunTaskOptions {
|
|
26
|
+
/** false: skip the task mutex, its heartbeat and the in-process guard (the caller holds a lock of its own). */
|
|
27
|
+
lock: boolean;
|
|
28
|
+
/** true: rethrow the task's error after history is written, instead of resolving with `{ error: true }`. */
|
|
29
|
+
rethrow: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function getTaskDeclarations(name?: string): TaskDeclaration[];
|
|
32
|
+
/**
|
|
33
|
+
* Runs a task method with the `@Task` bookkeeping: `__tasks` state, a `__task_history` row and
|
|
34
|
+
* TaskSuccess / TaskFailed. The decorator calls it with `{ lock: true, rethrow: false }`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function runTask(decl: TaskDeclaration, thisArg: unknown, args: unknown[], opts: RunTaskOptions): Promise<unknown>;
|
|
14
37
|
/**
|
|
15
38
|
* Marks a method as a task: records runs in `__tasks` / `__task_history`, emits
|
|
16
39
|
* TaskSuccess / TaskFailed and, unless `taskStacking` is set, lets only one run
|
|
17
|
-
* happen at a time across all processes sharing the database.
|
|
40
|
+
* happen at a time across all processes sharing the database. The declaration is
|
|
41
|
+
* also recorded, so `@spinajs/scheduler` can schedule the method by task name.
|
|
18
42
|
*
|
|
19
43
|
* @param taskName - unique task name
|
|
20
44
|
* @param description - short description
|
|
21
45
|
* @param opts - see {@link TaskOptions}, defaults to {@link DEFAULT_TASK_OPTIONS}
|
|
22
46
|
*/
|
|
23
|
-
export declare function Task(taskName: string, description: string, opts?: Partial<TaskOptions>): (
|
|
47
|
+
export declare function Task(taskName: string, description: string, opts?: Partial<TaskOptions>): (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
|
|
24
48
|
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,OAAO,EAAE,MAAM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B,UAiB3F"}
|
package/lib/mjs/decorators.js
CHANGED
|
@@ -53,10 +53,112 @@ async function lockTask(name, opts, log) {
|
|
|
53
53
|
await mutex_release({ Name: mutexName });
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
+
const declarations = new Map();
|
|
57
|
+
export function getTaskDeclarations(name) {
|
|
58
|
+
if (name !== undefined) {
|
|
59
|
+
return [...(declarations.get(name) ?? [])];
|
|
60
|
+
}
|
|
61
|
+
return [...declarations.values()].flat();
|
|
62
|
+
}
|
|
63
|
+
function errorMessage(err) {
|
|
64
|
+
return err?.message ?? String(err);
|
|
65
|
+
}
|
|
66
|
+
const NO_LOCK = () => Promise.resolve();
|
|
67
|
+
/**
|
|
68
|
+
* Runs a task method with the `@Task` bookkeeping: `__tasks` state, a `__task_history` row and
|
|
69
|
+
* TaskSuccess / TaskFailed. The decorator calls it with `{ lock: true, rethrow: false }`.
|
|
70
|
+
*/
|
|
71
|
+
export async function runTask(decl, thisArg, args, opts) {
|
|
72
|
+
const log = DI.resolve('__log__', ['TASKS']);
|
|
73
|
+
log.info(`Executing task ${decl.name} ...`);
|
|
74
|
+
let task;
|
|
75
|
+
let unlock;
|
|
76
|
+
try {
|
|
77
|
+
task = await __task.getOrCreate(null, {
|
|
78
|
+
Name: decl.name,
|
|
79
|
+
Description: decl.description,
|
|
80
|
+
State: 'stopped',
|
|
81
|
+
});
|
|
82
|
+
const lock = opts.lock ? await lockTask(decl.name, decl.options, log) : NO_LOCK;
|
|
83
|
+
if (!lock) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
unlock = lock;
|
|
87
|
+
try {
|
|
88
|
+
task.State = 'running';
|
|
89
|
+
task.LastRunAt = DateTime.now();
|
|
90
|
+
await task.update();
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
await unlock();
|
|
94
|
+
throw err;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
log.error(err, `Cannot start task ${decl.name}`);
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
let taskResult = null;
|
|
102
|
+
let failure = null;
|
|
103
|
+
const start = DateTime.now();
|
|
104
|
+
try {
|
|
105
|
+
try {
|
|
106
|
+
taskResult = await decl.method.apply(thisArg, args);
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
failure = { error: err };
|
|
110
|
+
log.error(err, `Cannot execute task ${decl.name}`);
|
|
111
|
+
taskResult = {
|
|
112
|
+
error: true,
|
|
113
|
+
message: errorMessage(err),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
// An emit failure (queue outage) is logged only: it must not turn a run whose side effects
|
|
117
|
+
// already happened into a failure that a caller would retry.
|
|
118
|
+
try {
|
|
119
|
+
if (failure) {
|
|
120
|
+
await TaskFailed.emit({
|
|
121
|
+
TaskName: decl.name,
|
|
122
|
+
Reason: errorMessage(failure.error),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
await TaskSuccess.emit({
|
|
127
|
+
TaskName: decl.name,
|
|
128
|
+
});
|
|
129
|
+
log.success(`Task ${decl.name} executed !`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (emitErr) {
|
|
133
|
+
log.error(emitErr, `Cannot emit ${failure ? 'TaskFailed' : 'TaskSuccess'} for ${decl.name}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
try {
|
|
138
|
+
await unlock();
|
|
139
|
+
await task.update({
|
|
140
|
+
State: 'stopped',
|
|
141
|
+
});
|
|
142
|
+
await __task_history.insert({
|
|
143
|
+
TaskId: task.Id,
|
|
144
|
+
Result: taskResult,
|
|
145
|
+
Duration: DateTime.now().diff(start).milliseconds,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
log.error(err, `Cannot finalize task`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (failure && opts.rethrow) {
|
|
153
|
+
throw failure.error;
|
|
154
|
+
}
|
|
155
|
+
return taskResult;
|
|
156
|
+
}
|
|
56
157
|
/**
|
|
57
158
|
* Marks a method as a task: records runs in `__tasks` / `__task_history`, emits
|
|
58
159
|
* TaskSuccess / TaskFailed and, unless `taskStacking` is set, lets only one run
|
|
59
|
-
* happen at a time across all processes sharing the database.
|
|
160
|
+
* happen at a time across all processes sharing the database. The declaration is
|
|
161
|
+
* also recorded, so `@spinajs/scheduler` can schedule the method by task name.
|
|
60
162
|
*
|
|
61
163
|
* @param taskName - unique task name
|
|
62
164
|
* @param description - short description
|
|
@@ -66,72 +168,20 @@ export function Task(taskName, description, opts) {
|
|
|
66
168
|
const _name = _check_arg(_trim(), _non_empty())(taskName, 'Task name is empty');
|
|
67
169
|
const _description = _check_arg(_trim(), _non_empty())(description, 'Task description is empty');
|
|
68
170
|
const _opts = { ...DEFAULT_TASK_OPTIONS, ...opts };
|
|
69
|
-
return function (
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
task.State = 'running';
|
|
86
|
-
task.LastRunAt = DateTime.now();
|
|
87
|
-
await task.update();
|
|
88
|
-
}
|
|
89
|
-
catch (err) {
|
|
90
|
-
await unlock();
|
|
91
|
-
throw err;
|
|
92
|
-
}
|
|
93
|
-
let taskResult = null;
|
|
94
|
-
const start = DateTime.now();
|
|
95
|
-
try {
|
|
96
|
-
taskResult = await oldFunction.apply(this, args);
|
|
97
|
-
await TaskSuccess.emit({
|
|
98
|
-
TaskName: taskName,
|
|
99
|
-
});
|
|
100
|
-
log.success(`Task ${taskName} executed !`);
|
|
101
|
-
}
|
|
102
|
-
catch (err) {
|
|
103
|
-
log.error(err, `Cannot execute task ${taskName}`);
|
|
104
|
-
taskResult = {
|
|
105
|
-
error: true,
|
|
106
|
-
message: err.Message,
|
|
107
|
-
};
|
|
108
|
-
await TaskFailed.emit({
|
|
109
|
-
TaskName: taskName,
|
|
110
|
-
Reason: err.Message,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
finally {
|
|
114
|
-
try {
|
|
115
|
-
await unlock();
|
|
116
|
-
await task.update({
|
|
117
|
-
State: 'stopped',
|
|
118
|
-
});
|
|
119
|
-
await __task_history.insert({
|
|
120
|
-
TaskId: task.Id,
|
|
121
|
-
Result: taskResult,
|
|
122
|
-
Duration: DateTime.now().diff(start).milliseconds,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
catch (err) {
|
|
126
|
-
log.error(err, `Cannot finalize task`);
|
|
127
|
-
}
|
|
128
|
-
return taskResult;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
catch (err) {
|
|
132
|
-
log.error(err, `Cannot start task ${taskName}`);
|
|
133
|
-
throw err;
|
|
134
|
-
}
|
|
171
|
+
return function (target, propertyKey, descriptor) {
|
|
172
|
+
const isStatic = typeof target === 'function';
|
|
173
|
+
const decl = {
|
|
174
|
+
name: _name,
|
|
175
|
+
description: _description,
|
|
176
|
+
options: _opts,
|
|
177
|
+
target: isStatic ? target : target.constructor,
|
|
178
|
+
isStatic,
|
|
179
|
+
propertyKey,
|
|
180
|
+
method: descriptor.value,
|
|
181
|
+
};
|
|
182
|
+
declarations.set(_name, [...(declarations.get(_name) ?? []), decl]);
|
|
183
|
+
descriptor.value = function (...args) {
|
|
184
|
+
return runTask(decl, this, args, { lock: true, rethrow: false });
|
|
135
185
|
};
|
|
136
186
|
};
|
|
137
187
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC/E,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