refactor: rename worker `started` flag to `ready`
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 7 Jul 2023 23:05:03 +0000 (01:05 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 7 Jul 2023 23:05:03 +0000 (01:05 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/abstract-pool.ts
src/pools/worker-node.ts
src/pools/worker.ts
src/utility-types.ts

index 9da566212877c60c5135f095e812035c2d086260..53bce7d2b7523f6a819cc5fd2dba3cbf5c84cc6a 100644 (file)
@@ -968,9 +968,9 @@ export abstract class AbstractPool<
    */
   protected workerListener (): (message: MessageValue<Response>) => void {
     return message => {
-      if (message.workerId != null && message.started != null) {
-        // Worker started message received
-        this.handleWorkerStartedMessage(message)
+      if (message.workerId != null && message.ready != null) {
+        // Worker ready message received
+        this.handleWorkerReadyMessage(message)
       } else if (message.id != null) {
         // Task execution response received
         this.handleTaskExecutionResponse(message)
@@ -978,14 +978,14 @@ export abstract class AbstractPool<
     }
   }
 
-  private handleWorkerStartedMessage (message: MessageValue<Response>): void {
+  private handleWorkerReadyMessage (message: MessageValue<Response>): void {
     const worker = this.getWorkerById(message.workerId as number)
     if (worker != null) {
-      this.getWorkerInfo(this.getWorkerNodeKey(worker)).started =
-        message.started as boolean
+      this.getWorkerInfo(this.getWorkerNodeKey(worker)).ready =
+        message.ready as boolean
     } else {
       throw new Error(
-        `Worker started message received from unknown worker '${
+        `Worker ready message received from unknown worker '${
           message.workerId as number
         }'`
       )
index c2acd65b26290f576a1deb64630ceca5cb580466..0a6b8de79c9d47f5b5b8706f4781acd1fabd46ab 100644 (file)
@@ -75,7 +75,7 @@ implements IWorkerNode<Worker, Data> {
       id: this.getWorkerId(worker, workerType),
       type: workerType,
       dynamic: false,
-      started: true
+      ready: true
     }
   }
 
index 81b49d3bc4a0f02fb99f964b626fecae387c2d33..5b427a5620d93740d642625e30d69f2bfd3cba0a 100644 (file)
@@ -157,9 +157,9 @@ export interface WorkerInfo {
    */
   dynamic: boolean
   /**
-   * Started flag.
+   * Ready flag.
    */
-  started: boolean
+  ready: boolean
 }
 
 /**
index 2035235022d13f49cb39c98e3ea10b91cf7ca8ec..f1b773eb31196c5ca827759bbbf3f70a37fc1ae9 100644 (file)
@@ -82,9 +82,9 @@ export interface MessageValue<Data = unknown, ErrorData = unknown>
    */
   readonly statistics?: WorkerStatistics
   /**
-   * Whether the worker has started or not.
+   * Whether the worker is ready or not.
    */
-  readonly started?: boolean
+  readonly ready?: boolean
   /**
    * Whether the worker starts or stops its aliveness check.
    */