import { Task } from './taskbuffer.classes.task.js'; 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; taskExecutionTimeout: number; taskExecutionParallel: number; status: 'requesting' | 'gotRejected' | 'failed' | 'succeeded'; } export interface ITaskConsultationResult { considered: boolean; rank: string; reason: string; shouldTrigger: boolean; } export interface IDistributedCoordinatorConstructorOptions { /** * each execution should be announced */ announceDistributedDecisionInfoBasis: (distributedCoordinatorArg: DistributedCoordinator, infoBasisArg: IDistributedDecisionInfoBasis) => Promise updateDistributedDecisionInfoBasis: (distributedCoordinatorArg: DistributedCoordinator, infoBasisArg: IDistributedDecisionInfoBasis) => Promise } export class DistributedCoordinator { public options: IDistributedCoordinatorConstructorOptions; constructor(optionsArg: IDistributedCoordinatorConstructorOptions) { this.options = optionsArg; } public async announceDistributedDecisionInfoBasis(infoBasisArg: IDistributedDecisionInfoBasis): Promise { return this.options.announceDistributedDecisionInfoBasis(this, infoBasisArg); } public async updateDistributedDevisionInfoBasis(infoBasisArg: IDistributedDecisionInfoBasis): Promise { return this.options.updateDistributedDecisionInfoBasis(this, infoBasisArg) } }