From: Jérôme Benoit Date: Mon, 1 Mar 2021 13:20:34 +0000 (+0100) Subject: Rename Wrk -> WorkerAbstract X-Git-Tag: v1.0.1-0~102^2~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=fd1fdf1b7bd53ee19679eb9c7d83b2592c32aed7;p=e-mobility-charging-stations-simulator.git Rename Wrk -> WorkerAbstract Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 486b4fcd..297c0870 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -1,8 +1,8 @@ import Configuration from '../utils/Configuration'; import { StationWorkerData } from '../types/Worker'; import Utils from '../utils/Utils'; +import WorkerAbstract from '../worker/WorkerAbstract'; import WorkerFactory from '../worker/WorkerFactory'; -import Wrk from '../worker/Wrk'; import { isMainThread } from 'worker_threads'; import path from 'path'; @@ -10,7 +10,7 @@ export default class Bootstrap { private static instance: Bootstrap; private started: boolean; private workerScript: string; - private workerImplementationInstance: Wrk; + private workerImplementationInstance: WorkerAbstract; private constructor() { this.started = false; @@ -79,7 +79,7 @@ export default class Bootstrap { await this.start(); } - private getWorkerImplementationInstance(): Wrk { + private getWorkerImplementationInstance(): WorkerAbstract { if (!this.workerImplementationInstance) { this.workerImplementationInstance = WorkerFactory.getWorkerImplementation(this.workerScript, Configuration.getWorkerProcess(), { poolMaxSize: Configuration.getWorkerPoolMaxSize(), diff --git a/src/worker/Wrk.ts b/src/worker/WorkerAbstract.ts similarity index 83% rename from src/worker/Wrk.ts rename to src/worker/WorkerAbstract.ts index d29494a8..6a8a0a0f 100644 --- a/src/worker/Wrk.ts +++ b/src/worker/WorkerAbstract.ts @@ -1,12 +1,12 @@ import { WorkerData } from '../types/Worker'; -export default abstract class Wrk { +export default abstract class WorkerAbstract { protected workerScript: string; public abstract size: number; public abstract maxElementsPerWorker: number; /** - * Create a new `Wrk`. + * Create a new `Worker` implementation. * * @param {string} workerScript */ diff --git a/src/worker/WorkerDynamicPool.ts b/src/worker/WorkerDynamicPool.ts index d30f9b7a..e6b939d8 100644 --- a/src/worker/WorkerDynamicPool.ts +++ b/src/worker/WorkerDynamicPool.ts @@ -3,10 +3,10 @@ import { DynamicThreadPool, PoolOptions } from 'poolifier'; import Constants from '../utils/Constants'; import Utils from '../utils/Utils'; import { Worker } from 'worker_threads'; +import WorkerAbstract from './WorkerAbstract'; import { WorkerData } from '../types/Worker'; -import Wrk from './Wrk'; -export default class WorkerDynamicPool extends Wrk { +export default class WorkerDynamicPool extends WorkerAbstract { private pool: DynamicPool; /** @@ -40,6 +40,7 @@ export default class WorkerDynamicPool extends Wrk { * @return {Promise} * @public */ + // eslint-disable-next-line @typescript-eslint/require-await public async stop(): Promise { return this.pool.destroy(); } diff --git a/src/worker/WorkerFactory.ts b/src/worker/WorkerFactory.ts index dba59173..41fa1d89 100644 --- a/src/worker/WorkerFactory.ts +++ b/src/worker/WorkerFactory.ts @@ -1,14 +1,14 @@ import { WorkerOptions, WorkerProcessType } from '../types/Worker'; import Utils from '../utils/Utils'; +import WorkerAbstract from './WorkerAbstract'; import WorkerDynamicPool from './WorkerDynamicPool'; import WorkerSet from './WorkerSet'; import WorkerStaticPool from './WorkerStaticPool'; -import Wrk from './Wrk'; import { isMainThread } from 'worker_threads'; export default class WorkerFactory { - public static getWorkerImplementation(workerScript: string, workerProcessType: WorkerProcessType, options?: WorkerOptions): Wrk { + public static getWorkerImplementation(workerScript: string, workerProcessType: WorkerProcessType, options?: WorkerOptions): WorkerAbstract { if (!isMainThread) { throw new Error('Trying to get a worker implementation outside the main thread'); } diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index 6ea0a059..419243fe 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -3,9 +3,9 @@ import { WorkerEvents, WorkerSetElement } from '../types/Worker'; import Constants from '../utils/Constants'; import Utils from '../utils/Utils'; import { Worker } from 'worker_threads'; -import Wrk from './Wrk'; +import WorkerAbstract from './WorkerAbstract'; -export default class WorkerSet extends Wrk { +export default class WorkerSet extends WorkerAbstract { public maxElementsPerWorker: number; private workerSet: Set; diff --git a/src/worker/WorkerStaticPool.ts b/src/worker/WorkerStaticPool.ts index ca8c02a0..8e591948 100644 --- a/src/worker/WorkerStaticPool.ts +++ b/src/worker/WorkerStaticPool.ts @@ -3,10 +3,10 @@ import { FixedThreadPool, PoolOptions } from 'poolifier'; import Constants from '../utils/Constants'; import Utils from '../utils/Utils'; import { Worker } from 'worker_threads'; +import WorkerAbstract from './WorkerAbstract'; import { WorkerData } from '../types/Worker'; -import Wrk from './Wrk'; -export default class WorkerStaticPool extends Wrk { +export default class WorkerStaticPool extends WorkerAbstract { private pool: StaticPool; /**