Commit | Line | Data |
---|---|---|
6013bc53 | 1 | import Configuration from '../utils/Configuration'; |
a4624c96 JB |
2 | import WorkerDynamicPool from './WorkerDynamicPool'; |
3 | import { WorkerProcessType } from '../types/Worker'; | |
6013bc53 | 4 | import WorkerSet from './WorkerSet'; |
a4624c96 | 5 | import WorkerStaticPool from './WorkerStaticPool'; |
144cabe0 | 6 | import Wrk from './Wrk'; |
6013bc53 JB |
7 | |
8 | export default class WorkerFactory { | |
9 | public static getWorkerImpl(workerScript: string): Wrk { | |
a4624c96 JB |
10 | switch (Configuration.getWorkerProcess()) { |
11 | case WorkerProcessType.WORKER_SET: | |
12 | return new WorkerSet(workerScript, Configuration.getChargingStationsPerWorker()); | |
13 | case WorkerProcessType.STATIC_POOL: | |
14 | return new WorkerStaticPool(workerScript, Configuration.getWorkerPoolMaxSize()); | |
15 | case WorkerProcessType.DYNAMIC_POOL: | |
16 | return new WorkerDynamicPool(workerScript, Configuration.getWorkerPoolMinSize(), Configuration.getWorkerPoolMaxSize()); | |
17 | default: | |
18 | return null; | |
6013bc53 | 19 | } |
6013bc53 JB |
20 | } |
21 | } |