fix(core): update
This commit is contained in:
parent
e4f8be5603
commit
a2f6bccac2
@ -28,12 +28,13 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/taskbuffer#readme",
|
||||
"dependencies": {
|
||||
"@pushrocks/isounique": "^1.0.5",
|
||||
"@pushrocks/lik": "^6.0.0",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartlog": "^3.0.1",
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"@pushrocks/smartrx": "^3.0.0",
|
||||
"@pushrocks/smarttime": "^3.0.45"
|
||||
"@pushrocks/smarttime": "^4.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
@ -41,7 +42,7 @@
|
||||
"@gitzone/tsrun": "^1.2.39",
|
||||
"@gitzone/tstest": "^1.0.72",
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.6.3"
|
||||
"@types/node": "^18.11.18"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
403
pnpm-lock.yaml
generated
403
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/taskbuffer',
|
||||
version: '3.0.4',
|
||||
version: '3.0.5',
|
||||
description: 'flexible task management. TypeScript ready!'
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import * as plugins from './taskbuffer.plugins.js';
|
||||
* constains all data for the final coordinator to actually make an informed decision
|
||||
*/
|
||||
export interface IDistributedDecisionInfoBasis {
|
||||
submitterRandomId: string;
|
||||
taskName: string;
|
||||
taskVersion: string;
|
||||
taskExecutionTime: number;
|
||||
@ -21,8 +22,11 @@ export interface ITaskConsultationResult {
|
||||
}
|
||||
|
||||
export interface IDistributedCoordinatorConstructorOptions {
|
||||
announceDistributedDecisionInfoBasis: (infoBasisArg: IDistributedDecisionInfoBasis) => Promise<ITaskConsultationResult>
|
||||
updateDistributedDecisionInfoBasis: (infoBasisArg: IDistributedDecisionInfoBasis) => Promise<void>
|
||||
/**
|
||||
* each execution should be announced
|
||||
*/
|
||||
announceDistributedDecisionInfoBasis: (distributedCoordinatorArg: DistributedCoordinator, infoBasisArg: IDistributedDecisionInfoBasis) => Promise<ITaskConsultationResult>
|
||||
updateDistributedDecisionInfoBasis: (distributedCoordinatorArg: DistributedCoordinator, infoBasisArg: IDistributedDecisionInfoBasis) => Promise<void>
|
||||
}
|
||||
|
||||
export class DistributedCoordinator {
|
||||
@ -33,10 +37,10 @@ export class DistributedCoordinator {
|
||||
}
|
||||
|
||||
public async announceDistributedDecisionInfoBasis(infoBasisArg: IDistributedDecisionInfoBasis): Promise<ITaskConsultationResult> {
|
||||
return this.options.announceDistributedDecisionInfoBasis(infoBasisArg);
|
||||
return this.options.announceDistributedDecisionInfoBasis(this, infoBasisArg);
|
||||
}
|
||||
public async updateDistributedDevisionInfoBasis(infoBasisArg: IDistributedDecisionInfoBasis): Promise<void> {
|
||||
return this.options.updateDistributedDecisionInfoBasis(infoBasisArg)
|
||||
return this.options.updateDistributedDecisionInfoBasis(this, infoBasisArg)
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,7 @@ export interface ITaskManagerConstructorOptions {
|
||||
}
|
||||
|
||||
export class TaskManager {
|
||||
public randomId = plugins.isounique.uni();
|
||||
public taskMap = new plugins.lik.ObjectMap<Task>();
|
||||
private cronJobManager = new plugins.smarttime.CronManager();
|
||||
|
||||
@ -20,7 +21,7 @@ export class TaskManager {
|
||||
distributedCoordinator: null
|
||||
};
|
||||
|
||||
constructor(optionosArg: ITaskManagerConstructorOptions) {
|
||||
constructor(optionosArg: ITaskManagerConstructorOptions = {}) {
|
||||
this.options = Object.assign(this.options, optionosArg);
|
||||
}
|
||||
|
||||
@ -88,14 +89,22 @@ export class TaskManager {
|
||||
);
|
||||
if (this.options.distributedCoordinator) {
|
||||
console.log(`Found a distrubuted coordinator, performing distributed consultation.`);
|
||||
const announcementResult = this.options.distributedCoordinator.announceDistributedDecisionInfoBasis({
|
||||
const announcementResult = await this.options.distributedCoordinator.announceDistributedDecisionInfoBasis({
|
||||
submitterRandomId: this.randomId,
|
||||
status: 'requesting',
|
||||
taskExecutionParallel: 1,
|
||||
taskExecutionTime: triggerTimeArg,
|
||||
taskExecutionTimeout: taskToSchedule.timeout,
|
||||
taskName: taskToSchedule.name,
|
||||
taskVersion: taskToSchedule.version,
|
||||
})
|
||||
});
|
||||
|
||||
if (!announcementResult.shouldTrigger) {
|
||||
console.log('distributed coordinator result: NOT EXECUTING')
|
||||
return;
|
||||
} else {
|
||||
console.log('distributed coordinator result: CHOSEN AND EXECUTING')
|
||||
}
|
||||
}
|
||||
await taskToSchedule.trigger();
|
||||
});
|
||||
|
@ -1,8 +1,9 @@
|
||||
import * as smartlog from '@pushrocks/smartlog';
|
||||
import * as isounique from '@pushrocks/isounique';
|
||||
import * as lik from '@pushrocks/lik';
|
||||
import * as smartlog from '@pushrocks/smartlog';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartrx from '@pushrocks/smartrx';
|
||||
import * as smarttime from '@pushrocks/smarttime';
|
||||
|
||||
export { smartlog, lik, smartpromise, smartdelay, smartrx, smarttime };
|
||||
export { isounique, lik, smartlog, smartpromise, smartdelay, smartrx, smarttime };
|
||||
|
Loading…
Reference in New Issue
Block a user