Rename Wrk -> WorkerAbstract
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 1 Mar 2021 13:20:34 +0000 (14:20 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 1 Mar 2021 13:20:34 +0000 (14:20 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/Bootstrap.ts
src/worker/WorkerAbstract.ts [moved from src/worker/Wrk.ts with 83% similarity]
src/worker/WorkerDynamicPool.ts
src/worker/WorkerFactory.ts
src/worker/WorkerSet.ts
src/worker/WorkerStaticPool.ts

index 486b4fcd8445b805eb92f8eabeb4298b97db96b0..297c0870a14a2e9a44cd7dbb5c49139e241dafcb 100644 (file)
@@ -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<StationWorkerData>(this.workerScript, Configuration.getWorkerProcess(), {
         poolMaxSize: Configuration.getWorkerPoolMaxSize(),
similarity index 83%
rename from src/worker/Wrk.ts
rename to src/worker/WorkerAbstract.ts
index d29494a8f33282c1370234b247014622b4f2c279..6a8a0a0ff07dc9003816ea6f76ef9e356d22a1de 100644 (file)
@@ -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
    */
index d30f9b7a9bb4d2725c8f904099ee5db2af949fb9..e6b939d8b384f754d747b038d74b22d2f533e2b9 100644 (file)
@@ -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<T> extends Wrk {
+export default class WorkerDynamicPool<T> extends WorkerAbstract {
   private pool: DynamicPool;
 
   /**
@@ -40,6 +40,7 @@ export default class WorkerDynamicPool<T> extends Wrk {
    * @return {Promise<void>}
    * @public
    */
+  // eslint-disable-next-line @typescript-eslint/require-await
   public async stop(): Promise<void> {
     return this.pool.destroy();
   }
index dba59173510a3e63e33c7dafa191d444eb406385..41fa1d89715444ca5cd69b07f6684789f63b2ecc 100644 (file)
@@ -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<T>(workerScript: string, workerProcessType: WorkerProcessType, options?: WorkerOptions): Wrk {
+  public static getWorkerImplementation<T>(workerScript: string, workerProcessType: WorkerProcessType, options?: WorkerOptions): WorkerAbstract {
     if (!isMainThread) {
       throw new Error('Trying to get a worker implementation outside the main thread');
     }
index 6ea0a05964d2af13370c23c0dbb7b60ae0246775..419243fe7536b48a6087767ab9d01df9321d1fc6 100644 (file)
@@ -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<T> extends Wrk {
+export default class WorkerSet<T> extends WorkerAbstract {
   public maxElementsPerWorker: number;
   private workerSet: Set<WorkerSetElement>;
 
index ca8c02a0fa613dc1050a18559bd87f82989d16db..8e591948ba362fee9d7f63d45a2c3640808e7bee 100644 (file)
@@ -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<T> extends Wrk {
+export default class WorkerStaticPool<T> extends WorkerAbstract {
   private pool: StaticPool;
 
   /**