refactor: cleanup worker message handling code
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 6 Jul 2023 22:25:35 +0000 (00:25 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 6 Jul 2023 22:25:35 +0000 (00:25 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/worker/abstract-worker.ts

index b8b442ecd2c0e2521a2c82b899620aa22197fbd7..ba74409e2b5c53aa7ddb3c9a3b34ad8ec2515b11 100644 (file)
@@ -145,12 +145,12 @@ export abstract class AbstractWorker<
    * @param message - Message received.
    */
   protected messageListener (message: MessageValue<Data, Data>): void {
-    if (message.dynamic === true) {
-      // Worker dynamic message received
-      this.startCheckAlive()
-    } else if (message.statistics != null) {
+    if (message.statistics != null) {
       // Statistics message received
       this.statistics = message.statistics
+    } else if (message.dynamic === true) {
+      // Worker dynamic message received
+      this.startCheckAlive()
     } else if (message.id != null && message.data != null) {
       // Task message received
       const fn = this.getTaskFunction(message.name)