@alterior/tasks 3.13.3 → 3.13.4
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/dist/index.d.ts +4 -4
- package/dist/index.js +7 -7
- package/dist/task-runner.d.ts +18 -18
- package/dist/task-runner.js +35 -35
- package/dist/task-runner.js.map +1 -1
- package/dist/task-worker.d.ts +25 -25
- package/dist/task-worker.js +98 -98
- package/dist/task-worker.js.map +1 -1
- package/dist/tasks.d.ts +92 -92
- package/dist/tasks.js +156 -156
- package/dist/tasks.js.map +1 -1
- package/dist/tasks.module.d.ts +46 -46
- package/dist/tasks.module.js +96 -95
- package/dist/tasks.module.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/dist.esm/index.d.ts +4 -4
- package/dist.esm/index.js +4 -4
- package/dist.esm/task-runner.d.ts +18 -18
- package/dist.esm/task-runner.js +32 -32
- package/dist.esm/task-runner.js.map +1 -1
- package/dist.esm/task-worker.d.ts +25 -25
- package/dist.esm/task-worker.js +94 -94
- package/dist.esm/task-worker.js.map +1 -1
- package/dist.esm/tasks.d.ts +92 -92
- package/dist.esm/tasks.js +151 -151
- package/dist.esm/tasks.js.map +1 -1
- package/dist.esm/tasks.module.d.ts +46 -46
- package/dist.esm/tasks.module.js +93 -92
- package/dist.esm/tasks.module.js.map +1 -1
- package/dist.esm/test.d.ts +1 -1
- package/package.json +11 -11
- package/src/tasks.module.ts +1 -1
- package/tsconfig.esm.tsbuildinfo +1 -0
- package/tsconfig.json +0 -2
- package/tsconfig.tsbuildinfo +1 -5845
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './tasks';
|
|
2
|
-
export * from './task-runner';
|
|
3
|
-
export * from './task-worker';
|
|
4
|
-
export * from './tasks.module';
|
|
1
|
+
export * from './tasks';
|
|
2
|
+
export * from './task-runner';
|
|
3
|
+
export * from './task-worker';
|
|
4
|
+
export * from './tasks.module';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./tasks"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./task-runner"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./task-worker"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./tasks.module"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./tasks"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./task-runner"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./task-worker"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./tasks.module"), exports);
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/task-runner.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { TaskWorkerRegistry, Constructor, Worker, RemoteWorker, RemoteService } from "./tasks";
|
|
2
|
-
export declare class TaskRunner {
|
|
3
|
-
private _registry;
|
|
4
|
-
constructor(_registry: TaskWorkerRegistry);
|
|
5
|
-
get registry(): TaskWorkerRegistry;
|
|
6
|
-
/**
|
|
7
|
-
* Acquire a Remote for the given service where any calls to the remote will
|
|
8
|
-
* resolve to a QueueJob which can be further interacted with. Promise will
|
|
9
|
-
* resolve once the item has been successfully delivered to the event queue.
|
|
10
|
-
*/
|
|
11
|
-
worker<T extends Worker>(workerClass: Constructor<T>): RemoteWorker<T>;
|
|
12
|
-
/**
|
|
13
|
-
* Acquire a Remote for the given service where any calls to the remote will await
|
|
14
|
-
* the full completion of the remote call and resolve to the return value of the
|
|
15
|
-
* remote function. If you only want to enqueue a task, use `worker()` instead.
|
|
16
|
-
*/
|
|
17
|
-
service<T extends Worker>(workerClass: Constructor<T>): RemoteService<T>;
|
|
18
|
-
}
|
|
1
|
+
import { TaskWorkerRegistry, Constructor, Worker, RemoteWorker, RemoteService } from "./tasks";
|
|
2
|
+
export declare class TaskRunner {
|
|
3
|
+
private _registry;
|
|
4
|
+
constructor(_registry: TaskWorkerRegistry);
|
|
5
|
+
get registry(): TaskWorkerRegistry;
|
|
6
|
+
/**
|
|
7
|
+
* Acquire a Remote for the given service where any calls to the remote will
|
|
8
|
+
* resolve to a QueueJob which can be further interacted with. Promise will
|
|
9
|
+
* resolve once the item has been successfully delivered to the event queue.
|
|
10
|
+
*/
|
|
11
|
+
worker<T extends Worker>(workerClass: Constructor<T>): RemoteWorker<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Acquire a Remote for the given service where any calls to the remote will await
|
|
14
|
+
* the full completion of the remote call and resolve to the return value of the
|
|
15
|
+
* remote function. If you only want to enqueue a task, use `worker()` instead.
|
|
16
|
+
*/
|
|
17
|
+
service<T extends Worker>(workerClass: Constructor<T>): RemoteService<T>;
|
|
18
|
+
}
|
|
19
19
|
//# sourceMappingURL=task-runner.d.ts.map
|
package/dist/task-runner.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TaskRunner = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const di_1 = require("@alterior/di");
|
|
6
|
-
const tasks_1 = require("./tasks");
|
|
7
|
-
let TaskRunner = class TaskRunner {
|
|
8
|
-
constructor(_registry) {
|
|
9
|
-
this._registry = _registry;
|
|
10
|
-
}
|
|
11
|
-
get registry() {
|
|
12
|
-
return this._registry;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Acquire a Remote for the given service where any calls to the remote will
|
|
16
|
-
* resolve to a QueueJob which can be further interacted with. Promise will
|
|
17
|
-
* resolve once the item has been successfully delivered to the event queue.
|
|
18
|
-
*/
|
|
19
|
-
worker(workerClass) {
|
|
20
|
-
return this.registry.get(workerClass).async;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Acquire a Remote for the given service where any calls to the remote will await
|
|
24
|
-
* the full completion of the remote call and resolve to the return value of the
|
|
25
|
-
* remote function. If you only want to enqueue a task, use `worker()` instead.
|
|
26
|
-
*/
|
|
27
|
-
service(workerClass) {
|
|
28
|
-
return this.registry.get(workerClass).sync;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
TaskRunner =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskRunner = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const di_1 = require("@alterior/di");
|
|
6
|
+
const tasks_1 = require("./tasks");
|
|
7
|
+
let TaskRunner = class TaskRunner {
|
|
8
|
+
constructor(_registry) {
|
|
9
|
+
this._registry = _registry;
|
|
10
|
+
}
|
|
11
|
+
get registry() {
|
|
12
|
+
return this._registry;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Acquire a Remote for the given service where any calls to the remote will
|
|
16
|
+
* resolve to a QueueJob which can be further interacted with. Promise will
|
|
17
|
+
* resolve once the item has been successfully delivered to the event queue.
|
|
18
|
+
*/
|
|
19
|
+
worker(workerClass) {
|
|
20
|
+
return this.registry.get(workerClass).async;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Acquire a Remote for the given service where any calls to the remote will await
|
|
24
|
+
* the full completion of the remote call and resolve to the return value of the
|
|
25
|
+
* remote function. If you only want to enqueue a task, use `worker()` instead.
|
|
26
|
+
*/
|
|
27
|
+
service(workerClass) {
|
|
28
|
+
return this.registry.get(workerClass).sync;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.TaskRunner = TaskRunner;
|
|
32
|
+
exports.TaskRunner = TaskRunner = tslib_1.__decorate([
|
|
33
|
+
(0, di_1.Injectable)(),
|
|
34
|
+
tslib_1.__metadata("design:paramtypes", [tasks_1.TaskWorkerRegistry])
|
|
35
|
+
], TaskRunner);
|
|
36
36
|
//# sourceMappingURL=task-runner.js.map
|
package/dist/task-runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-runner.js","sourceRoot":"","sources":["../src/task-runner.ts"],"names":[],"mappings":";;;;AAAA,qCAAkD;AAClD,mCAAgL;AAIzK,IAAM,UAAU,GAAhB,MAAM,UAAU;IACnB,YACY,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAE1C,CAAC;IAED,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAmB,WAA4B;QACjD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAI,WAAW,CAAC,CAAC,KAAK,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAmB,WAA4B;QAClD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAI,WAAW,CAAC,CAAC,IAAI,CAAC;IAClD,CAAC;CACJ,CAAA;AA3BY,UAAU;IADtB,IAAA,eAAU,GAAE;6CAGe,0BAAkB;GAFjC,UAAU,CA2BtB
|
|
1
|
+
{"version":3,"file":"task-runner.js","sourceRoot":"","sources":["../src/task-runner.ts"],"names":[],"mappings":";;;;AAAA,qCAAkD;AAClD,mCAAgL;AAIzK,IAAM,UAAU,GAAhB,MAAM,UAAU;IACnB,YACY,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAE1C,CAAC;IAED,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAmB,WAA4B;QACjD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAI,WAAW,CAAC,CAAC,KAAK,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAmB,WAA4B;QAClD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAI,WAAW,CAAC,CAAC,IAAI,CAAC;IAClD,CAAC;CACJ,CAAA;AA3BY,gCAAU;qBAAV,UAAU;IADtB,IAAA,eAAU,GAAE;6CAGe,0BAAkB;GAFjC,UAAU,CA2BtB"}
|
package/dist/task-worker.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { Injector } from "@alterior/di";
|
|
2
|
-
import { TaskJob, TaskModuleOptions, TaskQueueClient, Worker } from "./tasks";
|
|
3
|
-
import { ApplicationOptions } from "@alterior/runtime";
|
|
4
|
-
import { Logger } from "@alterior/logging";
|
|
5
|
-
export interface TaskHandler {
|
|
6
|
-
worker: Worker;
|
|
7
|
-
handler: (methodName: string, args: any[]) => Promise<any>;
|
|
8
|
-
}
|
|
9
|
-
export declare class TaskWorker {
|
|
10
|
-
private _injector;
|
|
11
|
-
private _client;
|
|
12
|
-
private _options;
|
|
13
|
-
private _appOptions;
|
|
14
|
-
private _logger;
|
|
15
|
-
constructor(_injector: Injector, _client: TaskQueueClient, _options: TaskModuleOptions, _appOptions: ApplicationOptions, _logger: Logger);
|
|
16
|
-
get injector(): Injector;
|
|
17
|
-
get options(): TaskModuleOptions;
|
|
18
|
-
get appOptions(): ApplicationOptions;
|
|
19
|
-
private _taskHandlers;
|
|
20
|
-
get queue(): import("./tasks").Queue<TaskJob>;
|
|
21
|
-
stop(): void;
|
|
22
|
-
start(): void;
|
|
23
|
-
registerHandler(name: string, handler: TaskHandler): void;
|
|
24
|
-
registerClasses(taskClasses: Function[]): void;
|
|
25
|
-
}
|
|
1
|
+
import { Injector } from "@alterior/di";
|
|
2
|
+
import { TaskJob, TaskModuleOptions, TaskQueueClient, Worker } from "./tasks";
|
|
3
|
+
import { ApplicationOptions } from "@alterior/runtime";
|
|
4
|
+
import { Logger } from "@alterior/logging";
|
|
5
|
+
export interface TaskHandler {
|
|
6
|
+
worker: Worker;
|
|
7
|
+
handler: (methodName: string, args: any[]) => Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
export declare class TaskWorker {
|
|
10
|
+
private _injector;
|
|
11
|
+
private _client;
|
|
12
|
+
private _options;
|
|
13
|
+
private _appOptions;
|
|
14
|
+
private _logger;
|
|
15
|
+
constructor(_injector: Injector, _client: TaskQueueClient, _options: TaskModuleOptions, _appOptions: ApplicationOptions, _logger: Logger);
|
|
16
|
+
get injector(): Injector;
|
|
17
|
+
get options(): TaskModuleOptions;
|
|
18
|
+
get appOptions(): ApplicationOptions;
|
|
19
|
+
private _taskHandlers;
|
|
20
|
+
get queue(): import("./tasks").Queue<TaskJob>;
|
|
21
|
+
stop(): void;
|
|
22
|
+
start(): void;
|
|
23
|
+
registerHandler(name: string, handler: TaskHandler): void;
|
|
24
|
+
registerClasses(taskClasses: Function[]): void;
|
|
25
|
+
}
|
|
26
26
|
//# sourceMappingURL=task-worker.d.ts.map
|
package/dist/task-worker.js
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TaskWorker = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@alterior/common");
|
|
6
|
-
const di_1 = require("@alterior/di");
|
|
7
|
-
const tasks_1 = require("./tasks");
|
|
8
|
-
const util = tslib_1.__importStar(require("util"));
|
|
9
|
-
class TaskWorker {
|
|
10
|
-
constructor(_injector, _client, _options, _appOptions, _logger) {
|
|
11
|
-
this._injector = _injector;
|
|
12
|
-
this._client = _client;
|
|
13
|
-
this._options = _options;
|
|
14
|
-
this._appOptions = _appOptions;
|
|
15
|
-
this._logger = _logger;
|
|
16
|
-
this._taskHandlers = {};
|
|
17
|
-
if (!_injector)
|
|
18
|
-
throw new common_1.ArgumentNullError(`injector`);
|
|
19
|
-
if (!_options)
|
|
20
|
-
throw new common_1.ArgumentNullError(`options`);
|
|
21
|
-
if (!_appOptions)
|
|
22
|
-
throw new common_1.ArgumentNullError(`appOptions`);
|
|
23
|
-
}
|
|
24
|
-
get injector() {
|
|
25
|
-
return this._injector;
|
|
26
|
-
}
|
|
27
|
-
get options() {
|
|
28
|
-
return this._options;
|
|
29
|
-
}
|
|
30
|
-
get appOptions() {
|
|
31
|
-
return this._appOptions;
|
|
32
|
-
}
|
|
33
|
-
get queue() {
|
|
34
|
-
return this._client.queue;
|
|
35
|
-
}
|
|
36
|
-
stop() {
|
|
37
|
-
this.queue.close();
|
|
38
|
-
}
|
|
39
|
-
start() {
|
|
40
|
-
this.queue.process((job, done) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
let task = job.data;
|
|
42
|
-
if (!task || !task.id) {
|
|
43
|
-
console.log(`TaskWorker: Could not process invalid task:`);
|
|
44
|
-
console.dir(task, { depth: 3 });
|
|
45
|
-
console.log(`Associated job data:`);
|
|
46
|
-
console.dir(job, { depth: 3 });
|
|
47
|
-
yield job.discard();
|
|
48
|
-
done(new Error(`Invalid job task`), null);
|
|
49
|
-
}
|
|
50
|
-
let handler = this._taskHandlers[task.id];
|
|
51
|
-
if (!handler) {
|
|
52
|
-
console.error(`No handler for task ID '${task.id}'! Check that your worker class declares this task ID!`);
|
|
53
|
-
console.info(`Task was: `);
|
|
54
|
-
console.dir(task, { depth: 3 });
|
|
55
|
-
console.info(`Registered worker IDs: ${Object.keys(this._taskHandlers).join(', ')}`);
|
|
56
|
-
}
|
|
57
|
-
yield this._logger.withContext({ host: 'tasks', worker: handler.worker }, `TaskWorker | ${handler.worker.constructor.name}.${task.method}(${task.args.map(x => util.inspect(x, false, 2)).join(', ')})`, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
this._logger.info(`TaskWorker: ${task.method}() of worker ${handler.worker.constructor.name} (ID '${task.id}')`);
|
|
59
|
-
try {
|
|
60
|
-
let result = yield handler.handler(task.method, task.args);
|
|
61
|
-
done(undefined, result);
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
console.error(`Caught error while running task ${job.data.id}.${job.data.method || 'execute'}():`);
|
|
65
|
-
console.error(e);
|
|
66
|
-
done(e);
|
|
67
|
-
}
|
|
68
|
-
}));
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
registerHandler(name, handler) {
|
|
72
|
-
this._taskHandlers[name] = handler;
|
|
73
|
-
}
|
|
74
|
-
registerClasses(taskClasses) {
|
|
75
|
-
let providers = taskClasses;
|
|
76
|
-
let ownInjector = di_1.ReflectiveInjector.resolveAndCreate(providers, this.injector);
|
|
77
|
-
let allRoutes = [];
|
|
78
|
-
let tasks = taskClasses.map(taskClass => {
|
|
79
|
-
let id = taskClass.name;
|
|
80
|
-
let annotation = tasks_1.TaskAnnotation.getForClass(taskClass);
|
|
81
|
-
let instance = ownInjector.get(taskClass);
|
|
82
|
-
if (instance.name)
|
|
83
|
-
id = instance.name;
|
|
84
|
-
if (annotation && annotation.id)
|
|
85
|
-
id = annotation.id;
|
|
86
|
-
this.registerHandler(id, {
|
|
87
|
-
worker: instance,
|
|
88
|
-
handler: (methodName, args) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
let impl = instance.constructor.prototype[methodName];
|
|
90
|
-
if (typeof impl !== 'function' || methodName.startsWith('_'))
|
|
91
|
-
throw new common_1.InvalidOperationError(`Invalid task method ${methodName}`);
|
|
92
|
-
return yield instance[methodName](...args);
|
|
93
|
-
})
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
exports.TaskWorker = TaskWorker;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskWorker = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@alterior/common");
|
|
6
|
+
const di_1 = require("@alterior/di");
|
|
7
|
+
const tasks_1 = require("./tasks");
|
|
8
|
+
const util = tslib_1.__importStar(require("util"));
|
|
9
|
+
class TaskWorker {
|
|
10
|
+
constructor(_injector, _client, _options, _appOptions, _logger) {
|
|
11
|
+
this._injector = _injector;
|
|
12
|
+
this._client = _client;
|
|
13
|
+
this._options = _options;
|
|
14
|
+
this._appOptions = _appOptions;
|
|
15
|
+
this._logger = _logger;
|
|
16
|
+
this._taskHandlers = {};
|
|
17
|
+
if (!_injector)
|
|
18
|
+
throw new common_1.ArgumentNullError(`injector`);
|
|
19
|
+
if (!_options)
|
|
20
|
+
throw new common_1.ArgumentNullError(`options`);
|
|
21
|
+
if (!_appOptions)
|
|
22
|
+
throw new common_1.ArgumentNullError(`appOptions`);
|
|
23
|
+
}
|
|
24
|
+
get injector() {
|
|
25
|
+
return this._injector;
|
|
26
|
+
}
|
|
27
|
+
get options() {
|
|
28
|
+
return this._options;
|
|
29
|
+
}
|
|
30
|
+
get appOptions() {
|
|
31
|
+
return this._appOptions;
|
|
32
|
+
}
|
|
33
|
+
get queue() {
|
|
34
|
+
return this._client.queue;
|
|
35
|
+
}
|
|
36
|
+
stop() {
|
|
37
|
+
this.queue.close();
|
|
38
|
+
}
|
|
39
|
+
start() {
|
|
40
|
+
this.queue.process((job, done) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
let task = job.data;
|
|
42
|
+
if (!task || !task.id) {
|
|
43
|
+
console.log(`TaskWorker: Could not process invalid task:`);
|
|
44
|
+
console.dir(task, { depth: 3 });
|
|
45
|
+
console.log(`Associated job data:`);
|
|
46
|
+
console.dir(job, { depth: 3 });
|
|
47
|
+
yield job.discard();
|
|
48
|
+
done(new Error(`Invalid job task`), null);
|
|
49
|
+
}
|
|
50
|
+
let handler = this._taskHandlers[task.id];
|
|
51
|
+
if (!handler) {
|
|
52
|
+
console.error(`No handler for task ID '${task.id}'! Check that your worker class declares this task ID!`);
|
|
53
|
+
console.info(`Task was: `);
|
|
54
|
+
console.dir(task, { depth: 3 });
|
|
55
|
+
console.info(`Registered worker IDs: ${Object.keys(this._taskHandlers).join(', ')}`);
|
|
56
|
+
}
|
|
57
|
+
yield this._logger.withContext({ host: 'tasks', worker: handler.worker }, `TaskWorker | ${handler.worker.constructor.name}.${task.method}(${task.args.map(x => util.inspect(x, false, 2)).join(', ')})`, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
this._logger.info(`TaskWorker: ${task.method}() of worker ${handler.worker.constructor.name} (ID '${task.id}')`);
|
|
59
|
+
try {
|
|
60
|
+
let result = yield handler.handler(task.method, task.args);
|
|
61
|
+
done(undefined, result);
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
console.error(`Caught error while running task ${job.data.id}.${job.data.method || 'execute'}():`);
|
|
65
|
+
console.error(e);
|
|
66
|
+
done(e);
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
registerHandler(name, handler) {
|
|
72
|
+
this._taskHandlers[name] = handler;
|
|
73
|
+
}
|
|
74
|
+
registerClasses(taskClasses) {
|
|
75
|
+
let providers = taskClasses;
|
|
76
|
+
let ownInjector = di_1.ReflectiveInjector.resolveAndCreate(providers, this.injector);
|
|
77
|
+
let allRoutes = [];
|
|
78
|
+
let tasks = taskClasses.map(taskClass => {
|
|
79
|
+
let id = taskClass.name;
|
|
80
|
+
let annotation = tasks_1.TaskAnnotation.getForClass(taskClass);
|
|
81
|
+
let instance = ownInjector.get(taskClass);
|
|
82
|
+
if (instance.name)
|
|
83
|
+
id = instance.name;
|
|
84
|
+
if (annotation && annotation.id)
|
|
85
|
+
id = annotation.id;
|
|
86
|
+
this.registerHandler(id, {
|
|
87
|
+
worker: instance,
|
|
88
|
+
handler: (methodName, args) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
let impl = instance.constructor.prototype[methodName];
|
|
90
|
+
if (typeof impl !== 'function' || methodName.startsWith('_'))
|
|
91
|
+
throw new common_1.InvalidOperationError(`Invalid task method ${methodName}`);
|
|
92
|
+
return yield instance[methodName](...args);
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.TaskWorker = TaskWorker;
|
|
99
99
|
//# sourceMappingURL=task-worker.js.map
|
package/dist/task-worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-worker.js","sourceRoot":"","sources":["../src/task-worker.ts"],"names":[],"mappings":";;;;AAAA,6CAA2F;AAC3F,qCAAsE;AACtE,mCAA8F;AAK9F,mDAA6B;AAO7B,MAAa,UAAU;IACnB,YACM,SAAoB,EACpB,OAAyB,EACnB,QAA4B,EAClC,WAAgC,EAChC,OAAgB;QAJhB,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAkB;QACnB,aAAQ,GAAR,QAAQ,CAAoB;QAClC,gBAAW,GAAX,WAAW,CAAqB;QAChC,YAAO,GAAP,OAAO,CAAS;QAyBd,kBAAa,GAAG,EAAE,CAAC;QAvB7B,IAAI,CAAC,SAAS;YACb,MAAM,IAAI,0BAAiB,CAAC,UAAU,CAAC,CAAC;QAEzC,IAAI,CAAC,QAAQ;YACZ,MAAM,IAAI,0BAAiB,CAAC,SAAS,CAAC,CAAC;QAExC,IAAI,CAAC,WAAW;YACf,MAAM,IAAI,0BAAiB,CAAC,YAAY,CAAC,CAAC;IAEzC,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAIJ,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,IAAI;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IAED,K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AG,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAEvC,IAAI,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC;YACxB,IAAI,UAAU,GAAG,sBAAc,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YACvD,IAAI,QAAQ,GAAY,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAEnD,IAAI,QAAQ,CAAC,IAAI;gBAChB,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC;YAEpB,IAAI,UAAU,IAAI,UAAU,CAAC,EAAE;gBAC9B,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC;YAEpB,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE;gBACxB,MAAM,EAAE,QAAQ;gBAChB,OAAO,EAAE,CAAO,UAAU,EAAE,IAAI,EAAE,EAAE;oBACnC,IAAI,IAAI,GAAG,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;oBAEtD,IAAI,OAAO,IAAI,KAAK,UAAU,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC;wBAC3D,MAAM,IAAI,8BAAqB,CAAC,uBAAuB,UAAU,EAAE,CAAC,CAAC;oBAEtE,OAAO,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBAC5C,CAAC,CAAA;aACD,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAzHD,gCAyHC"}
|
package/dist/tasks.d.ts
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { Annotation } from "@alterior/annotations";
|
|
2
|
-
import { InjectionToken, Injector } from "@alterior/di";
|
|
3
|
-
import BullQueue from "bull";
|
|
4
|
-
export interface TaskModuleOptions {
|
|
5
|
-
queueName?: string;
|
|
6
|
-
queueOptions?: BullQueue.QueueOptions;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* This injectable allows configuration of the task system.
|
|
10
|
-
* Include a provider for the injection token `QUEUE_OPTIONS`
|
|
11
|
-
* which provides an instance of this class.
|
|
12
|
-
*
|
|
13
|
-
* For instance: `[ provide: QUEUE_OPTIONS, useValue: new TaskClientOptionsRef({ optionsHere }) ]`
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
export declare class TaskModuleOptionsRef {
|
|
17
|
-
constructor(options: TaskModuleOptions);
|
|
18
|
-
options: TaskModuleOptions;
|
|
19
|
-
}
|
|
20
|
-
export interface TaskJob {
|
|
21
|
-
id: string;
|
|
22
|
-
method: string;
|
|
23
|
-
args: any[];
|
|
24
|
-
}
|
|
25
|
-
export declare const QUEUE_OPTIONS: InjectionToken<BullQueue.QueueOptions>;
|
|
26
|
-
export declare class TaskAnnotation extends Annotation {
|
|
27
|
-
readonly id?: string;
|
|
28
|
-
constructor(id?: string);
|
|
29
|
-
}
|
|
30
|
-
export declare const Task: (id?: string) => ClassDecorator & MethodDecorator & PropertyDecorator & ParameterDecorator;
|
|
31
|
-
export declare abstract class Worker {
|
|
32
|
-
abstract get name(): string;
|
|
33
|
-
get options(): JobOptions;
|
|
34
|
-
protected get currentJob(): QueueJob<TaskJob>;
|
|
35
|
-
}
|
|
36
|
-
export type RemoteService<T> = {
|
|
37
|
-
[P in keyof T]: T[P] extends (...args: any[]) => any ? (ReturnType<T[P]> extends Promise<any> ? T[P] : (...args: Parameters<T[P]>) => Promise<ReturnType<T[P]>>) : never;
|
|
38
|
-
} & {
|
|
39
|
-
withOptions(options: JobOptions): RemoteService<T>;
|
|
40
|
-
};
|
|
41
|
-
export type RemoteWorker<T> = {
|
|
42
|
-
[P in keyof T]: T[P] extends (...args: any[]) => any ? (...args: Parameters<T[P]>) => Promise<QueueJob<TaskJob>> : never;
|
|
43
|
-
} & {
|
|
44
|
-
withOptions(options: JobOptions): RemoteWorker<T>;
|
|
45
|
-
};
|
|
46
|
-
export type QueueOptions = BullQueue.QueueOptions;
|
|
47
|
-
export type JobOptions = BullQueue.JobOptions;
|
|
48
|
-
export type QueueJob<T> = BullQueue.Job<T>;
|
|
49
|
-
export type Queue<T> = BullQueue.Queue<T>;
|
|
50
|
-
export interface Constructor<T> {
|
|
51
|
-
new (...args: any[]): T;
|
|
52
|
-
}
|
|
53
|
-
export type PromiseWrap<T> = T extends PromiseLike<any> ? T : Promise<T>;
|
|
54
|
-
export declare class TaskWorkerProxy {
|
|
55
|
-
private static create;
|
|
56
|
-
static createAsync<T extends Worker>(queueClient: TaskQueueClient, id: string, options?: JobOptions): RemoteWorker<T>;
|
|
57
|
-
static createSync<T extends Worker>(queueClient: TaskQueueClient, id: string, options?: JobOptions): RemoteService<T>;
|
|
58
|
-
}
|
|
59
|
-
interface TaskWorkerEntry<T extends Worker = any> {
|
|
60
|
-
type: Constructor<T>;
|
|
61
|
-
local: T;
|
|
62
|
-
async: RemoteWorker<T>;
|
|
63
|
-
sync: RemoteService<T>;
|
|
64
|
-
}
|
|
65
|
-
export declare class TaskQueueClient {
|
|
66
|
-
private optionsRef;
|
|
67
|
-
constructor(optionsRef: TaskModuleOptionsRef);
|
|
68
|
-
_queue: BullQueue.Queue;
|
|
69
|
-
get queue(): Queue<TaskJob>;
|
|
70
|
-
/**
|
|
71
|
-
* Get the task client options. See
|
|
72
|
-
*/
|
|
73
|
-
get options(): TaskModuleOptions;
|
|
74
|
-
get queueName(): string;
|
|
75
|
-
get queueOptions(): BullQueue.QueueOptions;
|
|
76
|
-
/**
|
|
77
|
-
* Enqueue a new task. To handle the task on the worker side, register for it with `.process()`
|
|
78
|
-
*/
|
|
79
|
-
enqueue(data: TaskJob, opts?: JobOptions): Promise<QueueJob<TaskJob>>;
|
|
80
|
-
}
|
|
81
|
-
export declare class TaskWorkerRegistry {
|
|
82
|
-
private injector;
|
|
83
|
-
private client;
|
|
84
|
-
constructor(injector: Injector, client: TaskQueueClient);
|
|
85
|
-
private _entries;
|
|
86
|
-
private registerClass;
|
|
87
|
-
get all(): TaskWorkerEntry[];
|
|
88
|
-
get<T extends Worker>(cls: Constructor<T>): TaskWorkerEntry<T>;
|
|
89
|
-
getByName(name: string): TaskWorkerEntry<any>;
|
|
90
|
-
registerClasses(classes: Function[]): void;
|
|
91
|
-
}
|
|
92
|
-
export {};
|
|
1
|
+
import { Annotation } from "@alterior/annotations";
|
|
2
|
+
import { InjectionToken, Injector } from "@alterior/di";
|
|
3
|
+
import BullQueue from "bull";
|
|
4
|
+
export interface TaskModuleOptions {
|
|
5
|
+
queueName?: string;
|
|
6
|
+
queueOptions?: BullQueue.QueueOptions;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* This injectable allows configuration of the task system.
|
|
10
|
+
* Include a provider for the injection token `QUEUE_OPTIONS`
|
|
11
|
+
* which provides an instance of this class.
|
|
12
|
+
*
|
|
13
|
+
* For instance: `[ provide: QUEUE_OPTIONS, useValue: new TaskClientOptionsRef({ optionsHere }) ]`
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export declare class TaskModuleOptionsRef {
|
|
17
|
+
constructor(options: TaskModuleOptions);
|
|
18
|
+
options: TaskModuleOptions;
|
|
19
|
+
}
|
|
20
|
+
export interface TaskJob {
|
|
21
|
+
id: string;
|
|
22
|
+
method: string;
|
|
23
|
+
args: any[];
|
|
24
|
+
}
|
|
25
|
+
export declare const QUEUE_OPTIONS: InjectionToken<BullQueue.QueueOptions>;
|
|
26
|
+
export declare class TaskAnnotation extends Annotation {
|
|
27
|
+
readonly id?: string;
|
|
28
|
+
constructor(id?: string);
|
|
29
|
+
}
|
|
30
|
+
export declare const Task: (id?: string) => ClassDecorator & MethodDecorator & PropertyDecorator & ParameterDecorator;
|
|
31
|
+
export declare abstract class Worker {
|
|
32
|
+
abstract get name(): string;
|
|
33
|
+
get options(): JobOptions;
|
|
34
|
+
protected get currentJob(): QueueJob<TaskJob>;
|
|
35
|
+
}
|
|
36
|
+
export type RemoteService<T> = {
|
|
37
|
+
[P in keyof T]: T[P] extends (...args: any[]) => any ? (ReturnType<T[P]> extends Promise<any> ? T[P] : (...args: Parameters<T[P]>) => Promise<ReturnType<T[P]>>) : never;
|
|
38
|
+
} & {
|
|
39
|
+
withOptions(options: JobOptions): RemoteService<T>;
|
|
40
|
+
};
|
|
41
|
+
export type RemoteWorker<T> = {
|
|
42
|
+
[P in keyof T]: T[P] extends (...args: any[]) => any ? (...args: Parameters<T[P]>) => Promise<QueueJob<TaskJob>> : never;
|
|
43
|
+
} & {
|
|
44
|
+
withOptions(options: JobOptions): RemoteWorker<T>;
|
|
45
|
+
};
|
|
46
|
+
export type QueueOptions = BullQueue.QueueOptions;
|
|
47
|
+
export type JobOptions = BullQueue.JobOptions;
|
|
48
|
+
export type QueueJob<T> = BullQueue.Job<T>;
|
|
49
|
+
export type Queue<T> = BullQueue.Queue<T>;
|
|
50
|
+
export interface Constructor<T> {
|
|
51
|
+
new (...args: any[]): T;
|
|
52
|
+
}
|
|
53
|
+
export type PromiseWrap<T> = T extends PromiseLike<any> ? T : Promise<T>;
|
|
54
|
+
export declare class TaskWorkerProxy {
|
|
55
|
+
private static create;
|
|
56
|
+
static createAsync<T extends Worker>(queueClient: TaskQueueClient, id: string, options?: JobOptions): RemoteWorker<T>;
|
|
57
|
+
static createSync<T extends Worker>(queueClient: TaskQueueClient, id: string, options?: JobOptions): RemoteService<T>;
|
|
58
|
+
}
|
|
59
|
+
interface TaskWorkerEntry<T extends Worker = any> {
|
|
60
|
+
type: Constructor<T>;
|
|
61
|
+
local: T;
|
|
62
|
+
async: RemoteWorker<T>;
|
|
63
|
+
sync: RemoteService<T>;
|
|
64
|
+
}
|
|
65
|
+
export declare class TaskQueueClient {
|
|
66
|
+
private optionsRef;
|
|
67
|
+
constructor(optionsRef: TaskModuleOptionsRef);
|
|
68
|
+
_queue: BullQueue.Queue;
|
|
69
|
+
get queue(): Queue<TaskJob>;
|
|
70
|
+
/**
|
|
71
|
+
* Get the task client options. See
|
|
72
|
+
*/
|
|
73
|
+
get options(): TaskModuleOptions;
|
|
74
|
+
get queueName(): string;
|
|
75
|
+
get queueOptions(): BullQueue.QueueOptions;
|
|
76
|
+
/**
|
|
77
|
+
* Enqueue a new task. To handle the task on the worker side, register for it with `.process()`
|
|
78
|
+
*/
|
|
79
|
+
enqueue(data: TaskJob, opts?: JobOptions): Promise<QueueJob<TaskJob>>;
|
|
80
|
+
}
|
|
81
|
+
export declare class TaskWorkerRegistry {
|
|
82
|
+
private injector;
|
|
83
|
+
private client;
|
|
84
|
+
constructor(injector: Injector, client: TaskQueueClient);
|
|
85
|
+
private _entries;
|
|
86
|
+
private registerClass;
|
|
87
|
+
get all(): TaskWorkerEntry[];
|
|
88
|
+
get<T extends Worker>(cls: Constructor<T>): TaskWorkerEntry<T>;
|
|
89
|
+
getByName(name: string): TaskWorkerEntry<any>;
|
|
90
|
+
registerClasses(classes: Function[]): void;
|
|
91
|
+
}
|
|
92
|
+
export {};
|
|
93
93
|
//# sourceMappingURL=tasks.d.ts.map
|