X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2FWorkerAbstract.ts;h=bfb7933639eb1e3445e6bd71cafeef12807f2b3e;hb=d20f43b5644d96a9a166cd2ec5ddf87945ea45d7;hp=7c662d9dead4aa46e519b2519d1e560c774615b8;hpb=c3ee95af4edd541595e3873c8aa4c93d38e59474;p=e-mobility-charging-stations-simulator.git diff --git a/src/worker/WorkerAbstract.ts b/src/worker/WorkerAbstract.ts index 7c662d9d..bfb79336 100644 --- a/src/worker/WorkerAbstract.ts +++ b/src/worker/WorkerAbstract.ts @@ -1,9 +1,10 @@ -import Constants from '../utils/Constants'; -import { WorkerData } from '../types/Worker'; +import { WorkerData, WorkerOptions } from '../types/Worker'; + +import WorkerConstants from './WorkerConstants'; export default abstract class WorkerAbstract { protected readonly workerScript: string; - protected readonly workerStartDelay: number; + protected readonly workerOptions: WorkerOptions; public abstract readonly size: number; public abstract readonly maxElementsPerWorker: number | null; @@ -11,11 +12,24 @@ export default abstract class WorkerAbstract { * `WorkerAbstract` constructor. * * @param workerScript - * @param workerStartDelay + * @param workerOptions */ - constructor(workerScript: string, workerStartDelay: number = Constants.WORKER_START_DELAY) { + constructor( + workerScript: string, + workerOptions: WorkerOptions = { + workerStartDelay: WorkerConstants.DEFAULT_WORKER_START_DELAY, + elementStartDelay: WorkerConstants.DEFAULT_ELEMENT_START_DELAY, + poolMinSize: WorkerConstants.DEFAULT_POOL_MIN_SIZE, + poolMaxSize: WorkerConstants.DEFAULT_POOL_MAX_SIZE, + elementsPerWorker: WorkerConstants.DEFAULT_ELEMENTS_PER_WORKER, + poolOptions: {}, + messageHandler: () => { + /* This is intentional */ + }, + } + ) { this.workerScript = workerScript; - this.workerStartDelay = workerStartDelay; + this.workerOptions = workerOptions; } public abstract start(): Promise;