Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
ce258c76d2 | |||
4d2756b743 | |||
973678d635 | |||
28e7bad605 | |||
fb44dd47fc | |||
a2f6bccac2 |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/taskbuffer",
|
"name": "@pushrocks/taskbuffer",
|
||||||
"version": "3.0.4",
|
"version": "3.0.7",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "flexible task management. TypeScript ready!",
|
"description": "flexible task management. TypeScript ready!",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -28,12 +28,13 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/taskbuffer#readme",
|
"homepage": "https://gitlab.com/pushrocks/taskbuffer#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@pushrocks/isounique": "^1.0.5",
|
||||||
"@pushrocks/lik": "^6.0.0",
|
"@pushrocks/lik": "^6.0.0",
|
||||||
"@pushrocks/smartdelay": "^2.0.13",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
"@pushrocks/smartlog": "^3.0.1",
|
"@pushrocks/smartlog": "^3.0.1",
|
||||||
"@pushrocks/smartpromise": "^3.1.7",
|
"@pushrocks/smartpromise": "^3.1.7",
|
||||||
"@pushrocks/smartrx": "^3.0.0",
|
"@pushrocks/smartrx": "^3.0.0",
|
||||||
"@pushrocks/smarttime": "^3.0.45"
|
"@pushrocks/smarttime": "^4.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.63",
|
"@gitzone/tsbuild": "^2.1.63",
|
||||||
@ -41,7 +42,7 @@
|
|||||||
"@gitzone/tsrun": "^1.2.39",
|
"@gitzone/tsrun": "^1.2.39",
|
||||||
"@gitzone/tstest": "^1.0.72",
|
"@gitzone/tstest": "^1.0.72",
|
||||||
"@pushrocks/tapbundle": "^5.0.4",
|
"@pushrocks/tapbundle": "^5.0.4",
|
||||||
"@types/node": "^18.6.3"
|
"@types/node": "^18.11.18"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"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 = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/taskbuffer',
|
name: '@pushrocks/taskbuffer',
|
||||||
version: '3.0.4',
|
version: '3.0.7',
|
||||||
description: 'flexible task management. TypeScript ready!'
|
description: 'flexible task management. TypeScript ready!'
|
||||||
}
|
}
|
||||||
|
@ -6,3 +6,7 @@ export { TaskManager } from './taskbuffer.classes.taskmanager.js';
|
|||||||
export { TaskOnce } from './taskbuffer.classes.taskonce.js';
|
export { TaskOnce } from './taskbuffer.classes.taskonce.js';
|
||||||
export { TaskRunner } from './taskbuffer.classes.taskrunner.js';
|
export { TaskRunner } from './taskbuffer.classes.taskrunner.js';
|
||||||
export { TaskDebounced } from './taskbuffer.classes.taskdebounced.js';
|
export { TaskDebounced } from './taskbuffer.classes.taskdebounced.js';
|
||||||
|
import * as distributedCoordination from './taskbuffer.classes.distributedcoordinator.js';
|
||||||
|
export {
|
||||||
|
distributedCoordination
|
||||||
|
}
|
||||||
|
@ -5,6 +5,7 @@ import * as plugins from './taskbuffer.plugins.js';
|
|||||||
* constains all data for the final coordinator to actually make an informed decision
|
* constains all data for the final coordinator to actually make an informed decision
|
||||||
*/
|
*/
|
||||||
export interface IDistributedDecisionInfoBasis {
|
export interface IDistributedDecisionInfoBasis {
|
||||||
|
submitterRandomId: string;
|
||||||
taskName: string;
|
taskName: string;
|
||||||
taskVersion: string;
|
taskVersion: string;
|
||||||
taskExecutionTime: number;
|
taskExecutionTime: number;
|
||||||
@ -20,23 +21,7 @@ export interface ITaskConsultationResult {
|
|||||||
shouldTrigger: boolean;
|
shouldTrigger: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDistributedCoordinatorConstructorOptions {
|
export abstract class AbstractDistributedCoordinator {
|
||||||
announceDistributedDecisionInfoBasis: (infoBasisArg: IDistributedDecisionInfoBasis) => Promise<ITaskConsultationResult>
|
public abstract announceDistributedDecisionInfoBasis(infoBasisArg: IDistributedDecisionInfoBasis): Promise<ITaskConsultationResult>
|
||||||
updateDistributedDecisionInfoBasis: (infoBasisArg: IDistributedDecisionInfoBasis) => Promise<void>
|
public abstract updateDistributedDevisionInfoBasis(infoBasisArg: IDistributedDecisionInfoBasis): Promise<void>
|
||||||
}
|
|
||||||
|
|
||||||
export class DistributedCoordinator {
|
|
||||||
public options: IDistributedCoordinatorConstructorOptions;
|
|
||||||
|
|
||||||
constructor(optionsArg: IDistributedCoordinatorConstructorOptions) {
|
|
||||||
this.options = optionsArg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async announceDistributedDecisionInfoBasis(infoBasisArg: IDistributedDecisionInfoBasis): Promise<ITaskConsultationResult> {
|
|
||||||
return this.options.announceDistributedDecisionInfoBasis(infoBasisArg);
|
|
||||||
}
|
|
||||||
public async updateDistributedDevisionInfoBasis(infoBasisArg: IDistributedDecisionInfoBasis): Promise<void> {
|
|
||||||
return this.options.updateDistributedDecisionInfoBasis(infoBasisArg)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import * as plugins from './taskbuffer.plugins.js';
|
import * as plugins from './taskbuffer.plugins.js';
|
||||||
import { Task } from './taskbuffer.classes.task.js';
|
import { Task } from './taskbuffer.classes.task.js';
|
||||||
import { DistributedCoordinator } from './taskbuffer.classes.distributedcoordinator.js';
|
import { AbstractDistributedCoordinator } from './taskbuffer.classes.distributedcoordinator.js';
|
||||||
|
|
||||||
export interface ICronJob {
|
export interface ICronJob {
|
||||||
cronString: string;
|
cronString: string;
|
||||||
@ -9,10 +9,11 @@ export interface ICronJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ITaskManagerConstructorOptions {
|
export interface ITaskManagerConstructorOptions {
|
||||||
distributedCoordinator?: DistributedCoordinator
|
distributedCoordinator?: AbstractDistributedCoordinator
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TaskManager {
|
export class TaskManager {
|
||||||
|
public randomId = plugins.isounique.uni();
|
||||||
public taskMap = new plugins.lik.ObjectMap<Task>();
|
public taskMap = new plugins.lik.ObjectMap<Task>();
|
||||||
private cronJobManager = new plugins.smarttime.CronManager();
|
private cronJobManager = new plugins.smarttime.CronManager();
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ export class TaskManager {
|
|||||||
distributedCoordinator: null
|
distributedCoordinator: null
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(optionosArg: ITaskManagerConstructorOptions) {
|
constructor(optionosArg: ITaskManagerConstructorOptions = {}) {
|
||||||
this.options = Object.assign(this.options, optionosArg);
|
this.options = Object.assign(this.options, optionosArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,14 +89,22 @@ export class TaskManager {
|
|||||||
);
|
);
|
||||||
if (this.options.distributedCoordinator) {
|
if (this.options.distributedCoordinator) {
|
||||||
console.log(`Found a distrubuted coordinator, performing distributed consultation.`);
|
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',
|
status: 'requesting',
|
||||||
taskExecutionParallel: 1,
|
taskExecutionParallel: 1,
|
||||||
taskExecutionTime: triggerTimeArg,
|
taskExecutionTime: triggerTimeArg,
|
||||||
taskExecutionTimeout: taskToSchedule.timeout,
|
taskExecutionTimeout: taskToSchedule.timeout,
|
||||||
taskName: taskToSchedule.name,
|
taskName: taskToSchedule.name,
|
||||||
taskVersion: taskToSchedule.version,
|
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();
|
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 lik from '@pushrocks/lik';
|
||||||
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
import * as smartrx from '@pushrocks/smartrx';
|
import * as smartrx from '@pushrocks/smartrx';
|
||||||
import * as smarttime from '@pushrocks/smarttime';
|
import * as smarttime from '@pushrocks/smarttime';
|
||||||
|
|
||||||
export { smartlog, lik, smartpromise, smartdelay, smartrx, smarttime };
|
export { isounique, lik, smartlog, smartpromise, smartdelay, smartrx, smarttime };
|
||||||
|
Reference in New Issue
Block a user