@sidequest/engine 1.0.0-next.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -0
- package/dist/engine.cjs +27 -11
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.ts +3 -2
- package/dist/engine.js +28 -12
- package/dist/engine.js.map +1 -1
- package/dist/execution/executor-manager.cjs +23 -19
- package/dist/execution/executor-manager.cjs.map +1 -1
- package/dist/execution/executor-manager.d.ts +4 -7
- package/dist/execution/executor-manager.js +24 -20
- package/dist/execution/executor-manager.js.map +1 -1
- package/dist/execution/queue-manager.cjs +5 -2
- package/dist/execution/queue-manager.cjs.map +1 -1
- package/dist/execution/queue-manager.d.ts +4 -1
- package/dist/execution/queue-manager.js +5 -2
- package/dist/execution/queue-manager.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/job/job-builder.cjs +51 -9
- package/dist/job/job-builder.cjs.map +1 -1
- package/dist/job/job-builder.d.ts +22 -2
- package/dist/job/job-builder.js +52 -10
- package/dist/job/job-builder.js.map +1 -1
- package/dist/job/job-transitioner.cjs +1 -1
- package/dist/job/job-transitioner.cjs.map +1 -1
- package/dist/job/job-transitioner.js +1 -1
- package/dist/job/job-transitioner.js.map +1 -1
- package/dist/queue/grant-queue-config.cjs +4 -2
- package/dist/queue/grant-queue-config.cjs.map +1 -1
- package/dist/queue/grant-queue-config.d.ts +3 -1
- package/dist/queue/grant-queue-config.js +4 -2
- package/dist/queue/grant-queue-config.js.map +1 -1
- package/dist/shared-runner/runner-pool.cjs +9 -6
- package/dist/shared-runner/runner-pool.cjs.map +1 -1
- package/dist/shared-runner/runner-pool.d.ts +4 -2
- package/dist/shared-runner/runner-pool.js +9 -6
- package/dist/shared-runner/runner-pool.js.map +1 -1
- package/dist/shared-runner/runner.cjs +30 -2
- package/dist/shared-runner/runner.cjs.map +1 -1
- package/dist/shared-runner/runner.d.ts +20 -3
- package/dist/shared-runner/runner.js +30 -3
- package/dist/shared-runner/runner.js.map +1 -1
- package/dist/utils/import.cjs +13 -0
- package/dist/utils/import.cjs.map +1 -0
- package/dist/utils/import.d.ts +15 -0
- package/dist/utils/import.js +11 -0
- package/dist/utils/import.js.map +1 -0
- package/dist/workers/main.cjs +4 -4
- package/dist/workers/main.cjs.map +1 -1
- package/dist/workers/main.js +4 -4
- package/dist/workers/main.js.map +1 -1
- package/package.json +7 -5
- package/dist/job/job.cjs +0 -250
- package/dist/job/job.cjs.map +0 -1
- package/dist/job/job.d.ts +0 -178
- package/dist/job/job.js +0 -248
- package/dist/job/job.js.map +0 -1
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@sidequest/core');
|
|
6
|
+
var _import = require('../utils/import.cjs');
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Runs a job by dynamically importing its script and executing the specified class.
|
|
9
|
-
* @param jobData The job data
|
|
10
|
+
* @param jobData The job data containing script and class information
|
|
11
|
+
* @param config The non-nullable engine configuration.
|
|
10
12
|
* @returns A promise resolving to the job result.
|
|
11
13
|
*/
|
|
12
|
-
async function run(jobData) {
|
|
14
|
+
async function run({ jobData, config }) {
|
|
15
|
+
await injectSidequestConfig(config);
|
|
13
16
|
let script = {};
|
|
14
17
|
try {
|
|
15
18
|
core.logger("Runner").debug(`Importing job script "${jobData.script}"`);
|
|
@@ -34,6 +37,31 @@ async function run(jobData) {
|
|
|
34
37
|
core.logger("Runner").debug(`Executing job class "${jobData.class}" with args:`, jobData.args);
|
|
35
38
|
return job.perform(...jobData.args);
|
|
36
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Injects the provided Sidequest engine configuration into the job script.
|
|
42
|
+
*
|
|
43
|
+
* Dynamically imports the `Sidequest` module and applies the configuration,
|
|
44
|
+
* ensuring migrations are skipped. Logs the process and handles errors gracefully,
|
|
45
|
+
* allowing execution to proceed even if configuration injection fails.
|
|
46
|
+
*
|
|
47
|
+
* @param config - The engine configuration object to inject into Sidequest.
|
|
48
|
+
* @returns A promise that resolves to `true` if the configuration was injected successfully,
|
|
49
|
+
* or `false` if an error occurred.
|
|
50
|
+
*/
|
|
51
|
+
async function injectSidequestConfig(config) {
|
|
52
|
+
try {
|
|
53
|
+
core.logger("Runner").debug("Injecting Sidequest config into job script");
|
|
54
|
+
const { Sidequest } = await _import.importSidequest();
|
|
55
|
+
await Sidequest.configure({ ...config, skipMigration: true });
|
|
56
|
+
core.logger("Runner").debug("Successfully injected Sidequest config");
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
core.logger("Runner").warn(`Failed to inject Sidequest config: ${error instanceof Error ? error.message : String(error)}. Proceeding anyway.`);
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
37
64
|
|
|
38
65
|
exports.default = run;
|
|
66
|
+
exports.injectSidequestConfig = injectSidequestConfig;
|
|
39
67
|
//# sourceMappingURL=runner.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.cjs","sources":["../../src/shared-runner/runner.ts"],"sourcesContent":[null],"names":["logger","toErrorData"],"mappings":"
|
|
1
|
+
{"version":3,"file":"runner.cjs","sources":["../../src/shared-runner/runner.ts"],"sourcesContent":[null],"names":["logger","toErrorData","importSidequest"],"mappings":";;;;;;;AAIA;;;;;AAKG;AACY,eAAe,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,EAA8C,EAAA;AAC/F,IAAA,MAAM,qBAAqB,CAAC,MAAM,CAAC;IAEnC,IAAI,MAAM,GAAiC,EAAE;AAC7C,IAAA,IAAI;AACF,QAAAA,WAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAA,sBAAA,EAAyB,OAAO,CAAC,MAAM,CAAA,CAAA,CAAG,CAAC;QAClE,MAAM,IAAI,MAAM,OAAO,O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AAA,EAAwB,OAAO,CAAC,KAAK,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC;IACzF,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;AACrC;AAEA;;;;;;;;;;AAUG;AACI,eAAe,qBAAqB,CAAC,MAAoB,EAAA;AAC9D,IAAA,IAAI;QACFA,WAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,4CAA4C,CAAC;AACpE,QAAA,MAAM,EAAE,SAAS,EAAE,GAAG,MAAME,uBAAe,EAAE;AAC7C,QAAA,MAAM,SAAS,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;QAC7DF,WAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,wCAAwC,CAAC;AAChE,QAAA,OAAO,IAAI;IACb;IAAE,OAAO,KAAK,EAAE;QACdA,WAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CACnB,CAAA,mCAAA,EAAsC,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA,oBAAA,CAAsB,CACnH;AACD,QAAA,OAAO,KAAK;IACd;AACF;;;;;"}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
import { JobData, JobResult } from '@sidequest/core';
|
|
2
|
+
import { EngineConfig } from '../engine.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Runs a job by dynamically importing its script and executing the specified class.
|
|
5
|
-
* @param jobData The job data
|
|
6
|
+
* @param jobData The job data containing script and class information
|
|
7
|
+
* @param config The non-nullable engine configuration.
|
|
6
8
|
* @returns A promise resolving to the job result.
|
|
7
9
|
*/
|
|
8
|
-
declare function run(jobData
|
|
10
|
+
declare function run({ jobData, config }: {
|
|
11
|
+
jobData: JobData;
|
|
12
|
+
config: EngineConfig;
|
|
13
|
+
}): Promise<JobResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Injects the provided Sidequest engine configuration into the job script.
|
|
16
|
+
*
|
|
17
|
+
* Dynamically imports the `Sidequest` module and applies the configuration,
|
|
18
|
+
* ensuring migrations are skipped. Logs the process and handles errors gracefully,
|
|
19
|
+
* allowing execution to proceed even if configuration injection fails.
|
|
20
|
+
*
|
|
21
|
+
* @param config - The engine configuration object to inject into Sidequest.
|
|
22
|
+
* @returns A promise that resolves to `true` if the configuration was injected successfully,
|
|
23
|
+
* or `false` if an error occurred.
|
|
24
|
+
*/
|
|
25
|
+
declare function injectSidequestConfig(config: EngineConfig): Promise<boolean>;
|
|
9
26
|
|
|
10
|
-
export { run as default };
|
|
27
|
+
export { run as default, injectSidequestConfig };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { logger, toErrorData } from '@sidequest/core';
|
|
2
|
+
import { importSidequest } from '../utils/import.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Runs a job by dynamically importing its script and executing the specified class.
|
|
5
|
-
* @param jobData The job data
|
|
6
|
+
* @param jobData The job data containing script and class information
|
|
7
|
+
* @param config The non-nullable engine configuration.
|
|
6
8
|
* @returns A promise resolving to the job result.
|
|
7
9
|
*/
|
|
8
|
-
async function run(jobData) {
|
|
10
|
+
async function run({ jobData, config }) {
|
|
11
|
+
await injectSidequestConfig(config);
|
|
9
12
|
let script = {};
|
|
10
13
|
try {
|
|
11
14
|
logger("Runner").debug(`Importing job script "${jobData.script}"`);
|
|
@@ -30,6 +33,30 @@ async function run(jobData) {
|
|
|
30
33
|
logger("Runner").debug(`Executing job class "${jobData.class}" with args:`, jobData.args);
|
|
31
34
|
return job.perform(...jobData.args);
|
|
32
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Injects the provided Sidequest engine configuration into the job script.
|
|
38
|
+
*
|
|
39
|
+
* Dynamically imports the `Sidequest` module and applies the configuration,
|
|
40
|
+
* ensuring migrations are skipped. Logs the process and handles errors gracefully,
|
|
41
|
+
* allowing execution to proceed even if configuration injection fails.
|
|
42
|
+
*
|
|
43
|
+
* @param config - The engine configuration object to inject into Sidequest.
|
|
44
|
+
* @returns A promise that resolves to `true` if the configuration was injected successfully,
|
|
45
|
+
* or `false` if an error occurred.
|
|
46
|
+
*/
|
|
47
|
+
async function injectSidequestConfig(config) {
|
|
48
|
+
try {
|
|
49
|
+
logger("Runner").debug("Injecting Sidequest config into job script");
|
|
50
|
+
const { Sidequest } = await importSidequest();
|
|
51
|
+
await Sidequest.configure({ ...config, skipMigration: true });
|
|
52
|
+
logger("Runner").debug("Successfully injected Sidequest config");
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
logger("Runner").warn(`Failed to inject Sidequest config: ${error instanceof Error ? error.message : String(error)}. Proceeding anyway.`);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
33
60
|
|
|
34
|
-
export { run as default };
|
|
61
|
+
export { run as default, injectSidequestConfig };
|
|
35
62
|
//# sourceMappingURL=runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sources":["../../src/shared-runner/runner.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runner.js","sources":["../../src/shared-runner/runner.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA;;;;;AAKG;AACY,eAAe,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,EAA8C,EAAA;AAC/F,IAAA,MAAM,qBAAqB,CAAC,MAAM,CAAC;IAEnC,IAAI,MAAM,GAAiC,EAAE;AAC7C,IAAA,IAAI;AACF,QAAA,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAA,sBAAA,EAAyB,OAAO,CAAC,MAAM,CAAA,CAAA,CAAG,CAAC;QAClE,MAAM,IAAI,MAAM,OAAO,OAAO,CAAC,MAAM,CAAC,CAAiC;AACvE,QAAA,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAA,kCAAA,EAAqC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CAAC,IAAI,CAAC;AACrC;AAEA;;;;;;;;;;AAUG;AACI,eAAe,qBAAqB,CAAC,MAAoB,EAAA;AAC9D,IAAA,IAAI;QACF,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,4CAA4C,CAAC;AACpE,QAAA,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,eAAe,EAAE;AAC7C,QAAA,MAAM,SAAS,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;QAC7D,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,wCAAwC,CAAC;AAChE,QAAA,OAAO,IAAI;IACb;IAAE,OAAO,KAAK,EAAE;QACd,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CACnB,CAAA,mCAAA,EAAsC,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA,oBAAA,CAAsB,CACnH;AACD,QAAA,OAAO,KAAK;IACd;AACF;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Dynamically imports the "sidequest" module.
|
|
5
|
+
*
|
|
6
|
+
* @returns A promise that resolves to the imported "sidequest" module.
|
|
7
|
+
*/
|
|
8
|
+
async function importSidequest() {
|
|
9
|
+
return await import('sidequest');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.importSidequest = importSidequest;
|
|
13
|
+
//# sourceMappingURL=import.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.cjs","sources":["../../src/utils/import.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;AAIG;AACI,eAAe,eAAe,GAAA;AACnC,IAAA,OAAO,MAAM,OAAO,WAAW,CAAC;AAClC;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as sidequest from 'sidequest';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Dynamically imports the "sidequest" module.
|
|
5
|
+
*
|
|
6
|
+
* @returns A promise that resolves to the imported "sidequest" module.
|
|
7
|
+
*/
|
|
8
|
+
declare function importSidequest(): Promise<{
|
|
9
|
+
default: typeof sidequest;
|
|
10
|
+
Sidequest: {
|
|
11
|
+
configure: (config: EngineConfig) => Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
export { importSidequest };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamically imports the "sidequest" module.
|
|
3
|
+
*
|
|
4
|
+
* @returns A promise that resolves to the imported "sidequest" module.
|
|
5
|
+
*/
|
|
6
|
+
async function importSidequest() {
|
|
7
|
+
return await import('sidequest');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { importSidequest };
|
|
11
|
+
//# sourceMappingURL=import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.js","sources":["../../src/utils/import.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;AAIG;AACI,eAAe,eAAe,GAAA;AACnC,IAAA,OAAO,MAAM,OAAO,WAAW,CAAC;AAClC;;;;"}
|
package/dist/workers/main.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@sidequest/core');
|
|
4
|
-
var
|
|
4
|
+
var nodeCron = require('node-cron');
|
|
5
5
|
var engine = require('../engine.cjs');
|
|
6
6
|
var dispatcher = require('../execution/dispatcher.cjs');
|
|
7
7
|
var executorManager = require('../execution/executor-manager.cjs');
|
|
@@ -24,7 +24,7 @@ class MainWorker {
|
|
|
24
24
|
try {
|
|
25
25
|
const nonNullConfig = await this.engine.configure(sidequestConfig);
|
|
26
26
|
this.backend = this.engine.getBackend();
|
|
27
|
-
this.dispatcher = new dispatcher.Dispatcher(this.backend, new queueManager.QueueManager(this.backend, nonNullConfig.queues), new executorManager.ExecutorManager(this.backend, nonNullConfig
|
|
27
|
+
this.dispatcher = new dispatcher.Dispatcher(this.backend, new queueManager.QueueManager(this.backend, nonNullConfig.queues, nonNullConfig.queueDefaults), new executorManager.ExecutorManager(this.backend, nonNullConfig));
|
|
28
28
|
this.dispatcher.start();
|
|
29
29
|
await this.startCron(nonNullConfig.releaseStaleJobsIntervalMin, nonNullConfig.releaseStaleJobsMaxStaleMs, nonNullConfig.releaseStaleJobsMaxClaimedMs, nonNullConfig.cleanupFinishedJobsIntervalMin, nonNullConfig.cleanupFinishedJobsOlderThan);
|
|
30
30
|
}
|
|
@@ -56,7 +56,7 @@ class MainWorker {
|
|
|
56
56
|
throw new Error("Backend is not initialized. Cannot start stale jobs release cron.");
|
|
57
57
|
}
|
|
58
58
|
core.logger("Worker").debug(`Starting stale jobs release cron with interval: ${intervalMin} minutes`);
|
|
59
|
-
const releaseTask =
|
|
59
|
+
const releaseTask = nodeCron.schedule(`*/${intervalMin} * * * *`, async () => {
|
|
60
60
|
try {
|
|
61
61
|
core.logger("Worker").debug("Running stale jobs release task");
|
|
62
62
|
await releaseStaleJobs.releaseStaleJobs(this.backend, maxStaleMs, maxClaimedMs);
|
|
@@ -76,7 +76,7 @@ class MainWorker {
|
|
|
76
76
|
throw new Error("Backend is not initialized. Cannot start finished jobs cleanup cron.");
|
|
77
77
|
}
|
|
78
78
|
core.logger("Worker").debug(`Starting finished jobs cleanup cron with interval: ${intervalMin} minutes`);
|
|
79
|
-
const cleanupTask =
|
|
79
|
+
const cleanupTask = nodeCron.schedule(`*/${intervalMin} * * * *`, async () => {
|
|
80
80
|
try {
|
|
81
81
|
core.logger("Worker").debug("Running finished jobs cleanup task");
|
|
82
82
|
await cleanupFinishedJob.cleanupFinishedJobs(this.backend, cutoffMs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.cjs","sources":["../../src/workers/main.ts"],"sourcesContent":[null],"names":["Engine","Dispatcher","QueueManager","ExecutorManager","logger","releaseStaleJobs","cleanupFinishedJobs","gracefulShutdown"],"mappings":";;;;;;;;;;;;MAWa,UAAU,CAAA;IACrB,YAAY,GAAG,KAAK;AACZ,IAAA,UAAU;AACV,IAAA,MAAM,GAAG,IAAIA,aAAM,EAAE;AACrB,IAAA,OAAO;AAEf;;;AAGG;IACH,MAAM,SAAS,CAAC,eAA6B,EAAA;AAC3C,QAAA,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;AACtB,YAAA,IAAI;gBACF,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;gBAClE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAG;AAExC,gBAAA,IAAI,CAAC,UAAU,GAAG,IAAIC,qBAAU,CAC9B,IAAI,CAAC,OAAO,EACZ,IAAIC,yBAAY,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"main.cjs","sources":["../../src/workers/main.ts"],"sourcesContent":[null],"names":["Engine","Dispatcher","QueueManager","ExecutorManager","logger","cron","releaseStaleJobs","cleanupFinishedJobs","gracefulShutdown"],"mappings":";;;;;;;;;;;;MAWa,UAAU,CAAA;IACrB,YAAY,GAAG,KAAK;AACZ,IAAA,UAAU;AACV,IAAA,MAAM,GAAG,IAAIA,aAAM,EAAE;AACrB,IAAA,OAAO;AAEf;;;AAGG;IACH,MAAM,SAAS,CAAC,eAA6B,EAAA;AAC3C,QAAA,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;AACtB,YAAA,IAAI;gBACF,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;gBAClE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAG;AAExC,gBAAA,IAAI,CAAC,UAAU,GAAG,IAAIC,qBAAU,CAC9B,IAAI,CAAC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AAS,CAAC,eAAe,CAAC;YAChD;iBAAO;gBACLA,WAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,yDAAyD,CAAC;YAClF;QACF;AAAO,aAAA,IAAI,IAAI,KAAK,UAAU,EAAE;AAC9B,YAAA,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;gBACxBA,WAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,oDAAoD,CAAC;AAC3E,gBAAA,MAAM,MAAM,CAAC,QAAQ,EAAE;gBACvBA,WAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC;AAClD,gBAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YACjB;iBAAO;gBACLA,WAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,4DAA4D,CAAC;YACtF;QACF;AACF,IAAA,CAAC,CACF;AAED,IAAA,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,MAAK;QAC5BA,WAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,yCAAyC,CAAC;QACjE,OAAO,CAAC,IAAI,EAAE;AAChB,IAAA,CAAC,CAAC;IAEF,IAAI,OAAO,CAAC,IAAI;AAAE,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;AACzC;;;;"}
|
package/dist/workers/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger } from '@sidequest/core';
|
|
2
|
-
import
|
|
2
|
+
import nodeCron from 'node-cron';
|
|
3
3
|
import { Engine } from '../engine.js';
|
|
4
4
|
import { Dispatcher } from '../execution/dispatcher.js';
|
|
5
5
|
import { ExecutorManager } from '../execution/executor-manager.js';
|
|
@@ -22,7 +22,7 @@ class MainWorker {
|
|
|
22
22
|
try {
|
|
23
23
|
const nonNullConfig = await this.engine.configure(sidequestConfig);
|
|
24
24
|
this.backend = this.engine.getBackend();
|
|
25
|
-
this.dispatcher = new Dispatcher(this.backend, new QueueManager(this.backend, nonNullConfig.queues), new ExecutorManager(this.backend, nonNullConfig
|
|
25
|
+
this.dispatcher = new Dispatcher(this.backend, new QueueManager(this.backend, nonNullConfig.queues, nonNullConfig.queueDefaults), new ExecutorManager(this.backend, nonNullConfig));
|
|
26
26
|
this.dispatcher.start();
|
|
27
27
|
await this.startCron(nonNullConfig.releaseStaleJobsIntervalMin, nonNullConfig.releaseStaleJobsMaxStaleMs, nonNullConfig.releaseStaleJobsMaxClaimedMs, nonNullConfig.cleanupFinishedJobsIntervalMin, nonNullConfig.cleanupFinishedJobsOlderThan);
|
|
28
28
|
}
|
|
@@ -54,7 +54,7 @@ class MainWorker {
|
|
|
54
54
|
throw new Error("Backend is not initialized. Cannot start stale jobs release cron.");
|
|
55
55
|
}
|
|
56
56
|
logger("Worker").debug(`Starting stale jobs release cron with interval: ${intervalMin} minutes`);
|
|
57
|
-
const releaseTask =
|
|
57
|
+
const releaseTask = nodeCron.schedule(`*/${intervalMin} * * * *`, async () => {
|
|
58
58
|
try {
|
|
59
59
|
logger("Worker").debug("Running stale jobs release task");
|
|
60
60
|
await releaseStaleJobs(this.backend, maxStaleMs, maxClaimedMs);
|
|
@@ -74,7 +74,7 @@ class MainWorker {
|
|
|
74
74
|
throw new Error("Backend is not initialized. Cannot start finished jobs cleanup cron.");
|
|
75
75
|
}
|
|
76
76
|
logger("Worker").debug(`Starting finished jobs cleanup cron with interval: ${intervalMin} minutes`);
|
|
77
|
-
const cleanupTask =
|
|
77
|
+
const cleanupTask = nodeCron.schedule(`*/${intervalMin} * * * *`, async () => {
|
|
78
78
|
try {
|
|
79
79
|
logger("Worker").debug("Running finished jobs cleanup task");
|
|
80
80
|
await cleanupFinishedJobs(this.backend, cutoffMs);
|
package/dist/workers/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sources":["../../src/workers/main.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;MAWa,UAAU,CAAA;IACrB,YAAY,GAAG,KAAK;AACZ,I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C,IAAI,CAAC,oDAAoD,CAAC;AAC3E,gBAAA,MAAM,MAAM,CAAC,QAAQ,EAAE;gBACvB,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC;AAClD,gBAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YACjB;iBAAO;gBACL,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,4DAA4D,CAAC;YACtF;QACF;AACF,IAAA,CAAC,CACF;AAED,IAAA,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,MAAK;QAC5B,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,yCAAyC,CAAC;QACjE,OAAO,CAAC,IAAI,EAAE;AAChB,IAAA,CAAC,CAAC;IAEF,IAAI,OAAO,CAAC,IAAI;AAAE,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;AACzC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sidequest/engine",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "LGPL-3.0-or-later",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@sidequest/backend": "1.0.0
|
|
24
|
-
"@sidequest/core": "1.0.0
|
|
23
|
+
"@sidequest/backend": "1.0.0",
|
|
24
|
+
"@sidequest/core": "1.0.0",
|
|
25
25
|
"node-cron": "^4.1.1",
|
|
26
26
|
"piscina": "^5.1.2"
|
|
27
27
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"sidequest": "1.0.0"
|
|
30
|
+
},
|
|
31
|
+
"packageManager": "yarn@4.9.2"
|
|
30
32
|
}
|
package/dist/job/job.cjs
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var core = require('@sidequest/core');
|
|
4
|
-
var promises = require('fs/promises');
|
|
5
|
-
var url = require('url');
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Abstract base class for Sidequest jobs.
|
|
9
|
-
* Concrete job classes should extend this class and implement the `run` method.
|
|
10
|
-
*
|
|
11
|
-
* There are a few convenience methods that can be used to return early and trigger a transition:
|
|
12
|
-
* - `snooze(delay: number)`: Returns a SnoozeResult to delay the job execution for a specified time.
|
|
13
|
-
* - `retry(reason: string | Error, delay?: number)`: Returns a RetryResult to retry the job with an optional delay.
|
|
14
|
-
* - `fail(reason: string | Error)`: Returns a FailedResult to mark the job as failed with a reason.
|
|
15
|
-
* - `complete(result: unknown)`: Returns a CompletedResult to mark the job as completed with a result.
|
|
16
|
-
*
|
|
17
|
-
* Calling any of these methods without returning its result will do absolutely nothing. Thus, you need to return
|
|
18
|
-
* the result of any of these methods to trigger the job transition.
|
|
19
|
-
*
|
|
20
|
-
* If there is an uncaught error in the `run` method, it will automatically return a RetryResult with the error data.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```typescript
|
|
24
|
-
* class MyJob extends Job {
|
|
25
|
-
* async run(arg1: string, arg2: number): Promise<string> {
|
|
26
|
-
* // Your job logic here
|
|
27
|
-
* if (someCondition) {
|
|
28
|
-
* return this.snooze(1000); // Delay the job for 1 second
|
|
29
|
-
* }
|
|
30
|
-
* if (anotherCondition) {
|
|
31
|
-
* return this.retry(new Error("Retrying due to some condition"), 500); // Retry after 500ms
|
|
32
|
-
* }
|
|
33
|
-
* if (yetAnotherCondition) {
|
|
34
|
-
* return this.fail("Failed due to some reason"); // Mark the job as failed
|
|
35
|
-
* }
|
|
36
|
-
* // If everything is fine, return the result
|
|
37
|
-
* return this.complete("Job completed successfully"); // Mark the job as completed
|
|
38
|
-
* // Alternatively, you can just return a value, which will be treated as the job result:
|
|
39
|
-
* return "Job completed successfully";
|
|
40
|
-
* }
|
|
41
|
-
* }
|
|
42
|
-
*/
|
|
43
|
-
class Job {
|
|
44
|
-
scriptResolver;
|
|
45
|
-
// JobData properties
|
|
46
|
-
id;
|
|
47
|
-
script;
|
|
48
|
-
queue;
|
|
49
|
-
state;
|
|
50
|
-
class;
|
|
51
|
-
args;
|
|
52
|
-
constructor_args;
|
|
53
|
-
attempt;
|
|
54
|
-
max_attempts;
|
|
55
|
-
inserted_at;
|
|
56
|
-
available_at;
|
|
57
|
-
timeout;
|
|
58
|
-
result;
|
|
59
|
-
errors;
|
|
60
|
-
attempted_at;
|
|
61
|
-
completed_at;
|
|
62
|
-
failed_at;
|
|
63
|
-
canceled_at;
|
|
64
|
-
claimed_at;
|
|
65
|
-
claimed_by;
|
|
66
|
-
unique_digest;
|
|
67
|
-
uniqueness_config;
|
|
68
|
-
/**
|
|
69
|
-
* Initializes the job and resolves its script path.
|
|
70
|
-
*/
|
|
71
|
-
constructor() {
|
|
72
|
-
/* IMPORTANT: the build path resolution must be called here.
|
|
73
|
-
* This is important to ensure the path resolution is returning the Job implementation.
|
|
74
|
-
*/
|
|
75
|
-
this.scriptResolver = buildPath(this.constructor.name).then((script) => {
|
|
76
|
-
Object.assign(this, { script });
|
|
77
|
-
core.logger("Job").debug(`Job script resolved: ${script}`);
|
|
78
|
-
return script;
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Injects JobData properties into the job instance at runtime.
|
|
83
|
-
* @param jobData The job data to inject into this instance.
|
|
84
|
-
*/
|
|
85
|
-
injectJobData(jobData) {
|
|
86
|
-
core.logger("Job").debug(`Injecting job data into ${this.className}:`, jobData);
|
|
87
|
-
Object.assign(this, jobData);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* The class name of this job.
|
|
91
|
-
*/
|
|
92
|
-
get className() {
|
|
93
|
-
return this.constructor.name;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Waits until the job is ready (script path resolved).
|
|
97
|
-
* @returns A promise that resolves when ready.
|
|
98
|
-
*/
|
|
99
|
-
async ready() {
|
|
100
|
-
return await this.scriptResolver;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Returns a snooze result for this job.
|
|
104
|
-
* This will delay the job execution for the specified time by setting `available_at` to the current
|
|
105
|
-
* time plus the delay.
|
|
106
|
-
*
|
|
107
|
-
* @param delay The delay in milliseconds.
|
|
108
|
-
* @returns A SnoozeResult object.
|
|
109
|
-
*/
|
|
110
|
-
snooze(delay) {
|
|
111
|
-
core.logger("Job").debug(`Job ${this.className} snoozed for ${delay}ms`);
|
|
112
|
-
return { __is_job_transition__: true, type: "snooze", delay: delay };
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Returns a retry result for this job. It will increase one attempt and set the `attempted_at`
|
|
116
|
-
* to the current time. If the number of attempts is increased to the maximum allowed, the transition
|
|
117
|
-
* will mark the job as failed.
|
|
118
|
-
*
|
|
119
|
-
* @param reason The reason for retrying.
|
|
120
|
-
* @param delay Optional delay in milliseconds.
|
|
121
|
-
* @returns A RetryResult object.
|
|
122
|
-
*/
|
|
123
|
-
retry(reason, delay) {
|
|
124
|
-
const error = core.toErrorData(reason);
|
|
125
|
-
core.logger("Job").debug(`Job ${this.className} retrying due to: ${error.message}${delay ? ` after ${delay}ms` : ""}`);
|
|
126
|
-
return { __is_job_transition__: true, type: "retry", error, delay };
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Returns a failed result for this job. This method will prevent any retry attempts and will mark the
|
|
130
|
-
* job as failed indefinitely.
|
|
131
|
-
*
|
|
132
|
-
* @param reason The reason for failure.
|
|
133
|
-
* @returns A FailedResult object.
|
|
134
|
-
*/
|
|
135
|
-
fail(reason) {
|
|
136
|
-
const error = core.toErrorData(reason);
|
|
137
|
-
core.logger("Job").debug(`Job ${this.className} failed: ${error.message}`);
|
|
138
|
-
return { __is_job_transition__: true, type: "failed", error };
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Returns a completed result for this job.
|
|
142
|
-
* This method will mark the job as completed.
|
|
143
|
-
*
|
|
144
|
-
* @param result The result value.
|
|
145
|
-
* @returns A CompletedResult object.
|
|
146
|
-
*/
|
|
147
|
-
complete(result) {
|
|
148
|
-
core.logger("Job").debug(`Job ${this.className} completed.`);
|
|
149
|
-
return { __is_job_transition__: true, type: "completed", result };
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Runs the job and returns a JobResult.
|
|
153
|
-
* This method is intended to be used internally.
|
|
154
|
-
*
|
|
155
|
-
* @param args Arguments to pass to the run method.
|
|
156
|
-
* @returns A promise resolving to the job result.
|
|
157
|
-
*/
|
|
158
|
-
async perform(...args) {
|
|
159
|
-
try {
|
|
160
|
-
const result = await this.run(...args);
|
|
161
|
-
if (core.isJobResult(result)) {
|
|
162
|
-
return result;
|
|
163
|
-
}
|
|
164
|
-
return { __is_job_transition__: true, type: "completed", result };
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
core.logger("Job").debug(error);
|
|
168
|
-
const errorData = core.toErrorData(error);
|
|
169
|
-
return { __is_job_transition__: true, type: "retry", error: errorData };
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
// TODO need to test this with unit tests
|
|
174
|
-
/**
|
|
175
|
-
* Attempts to determine the file path where a given class is exported by analyzing the current call stack.
|
|
176
|
-
*
|
|
177
|
-
* This function inspects the stack trace of a newly created error to extract file paths,
|
|
178
|
-
* then checks each file to see if it exports the specified class. If found, returns the file path
|
|
179
|
-
* as a `file://` URI. If not found, returns the first file path in the stack as a fallback.
|
|
180
|
-
* Throws an error if no file paths can be determined.
|
|
181
|
-
*
|
|
182
|
-
* @param className - The name of the class to search for in the stack trace files.
|
|
183
|
-
* @returns A promise that resolves to the `file://` URI of the file exporting the class, or the first file in the stack.
|
|
184
|
-
* @throws If no file paths can be determined from the stack trace.
|
|
185
|
-
*/
|
|
186
|
-
async function buildPath(className) {
|
|
187
|
-
const err = new Error();
|
|
188
|
-
let stackLines = err.stack?.split("\n") ?? [];
|
|
189
|
-
stackLines = stackLines.slice(1);
|
|
190
|
-
core.logger("Job").debug(`Resolving script file path. Stack lines: ${stackLines.join("\n")}`);
|
|
191
|
-
const filePaths = stackLines
|
|
192
|
-
.map((line) => {
|
|
193
|
-
const match = /(file:\/\/)?(((\/?)(\w:))?([/\\].+)):\d+:\d+/.exec(line);
|
|
194
|
-
if (match) {
|
|
195
|
-
return `${match[5] ?? ""}${match[6].replaceAll("\\", "/")}`;
|
|
196
|
-
}
|
|
197
|
-
return null;
|
|
198
|
-
})
|
|
199
|
-
.filter(Boolean);
|
|
200
|
-
for (const filePath of filePaths) {
|
|
201
|
-
const hasExported = await hasClassExported(filePath, className);
|
|
202
|
-
if (hasExported) {
|
|
203
|
-
core.logger("Job").debug(`${filePath} exports class ${className}`);
|
|
204
|
-
return `file://${filePath}`;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
if (filePaths.length > 0) {
|
|
208
|
-
core.logger("Job").debug(`No class ${className} found in stack, returning first file path: ${filePaths[0]}`);
|
|
209
|
-
return `file://${filePaths[0]}`;
|
|
210
|
-
}
|
|
211
|
-
throw new Error("Could not determine the task path");
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Checks if a given file exports a class with the specified name.
|
|
215
|
-
*
|
|
216
|
-
* This function attempts to import the module at the provided file path and
|
|
217
|
-
* determines if it exports a class (either as a named export or as the default export)
|
|
218
|
-
* matching the given class name.
|
|
219
|
-
*
|
|
220
|
-
* @param filePath - The absolute path to the module file to check.
|
|
221
|
-
* @param className - The name of the class to look for in the module's exports.
|
|
222
|
-
* @returns A promise that resolves to `true` if the class is exported, or `false` otherwise.
|
|
223
|
-
*/
|
|
224
|
-
async function hasClassExported(filePath, className) {
|
|
225
|
-
try {
|
|
226
|
-
await promises.access(filePath);
|
|
227
|
-
}
|
|
228
|
-
catch {
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
try {
|
|
232
|
-
const moduleUrl = url.pathToFileURL(filePath).href;
|
|
233
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
234
|
-
const mod = await import(moduleUrl);
|
|
235
|
-
if (mod && typeof mod === "object" && className in mod && typeof mod[className] === "function") {
|
|
236
|
-
return true;
|
|
237
|
-
}
|
|
238
|
-
if ("default" in mod && typeof mod.default === "function" && mod.default.name === className) {
|
|
239
|
-
return true;
|
|
240
|
-
}
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
catch (e) {
|
|
244
|
-
core.logger().debug(e);
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
exports.Job = Job;
|
|
250
|
-
//# sourceMappingURL=job.cjs.map
|
package/dist/job/job.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"job.cjs","sources":["../../src/job/job.ts"],"sourcesContent":[null],"names":["logger","toErrorData","isJobResult","access","pathToFileURL"],"mappings":";;;;;;AAuBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCG;MACmB,GAAG,CAAA;AACf,IAAA,cAAc;;AAGb,IAAA,EAAE;AACF,IAAA,MAAM;AACN,IAAA,KAAK;AACL,IAAA,KAAK;AACL,IAAA,KAAK;AACL,IAAA,IAAI;AACJ,IAAA,gBAAgB;AAChB,IAAA,OAAO;AACP,IAAA,YAAY;AACZ,IAAA,WAAW;AACX,IAAA,YAAY;AACZ,IAAA,OAAO;AACP,IAAA,MAAM;AACN,IAAA,MAAM;AACN,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,SAAS;AACT,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,UAAU;AACV,IAAA,aAAa;AACb,IAAA,iBAAiB;AAE1B;;AAEG;AACH,IAAA,WAAA,GAAA;AACE;;AAEG;AACH,QAAA,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