Quellcode durchsuchen

Added ::getReturnCode to GearmanClient

This wraps the return code from the last created internal client when doEnqueue is executed.
orolin vor 11 Jahren
Ursprung
Commit
7b57568568
1 geänderte Dateien mit 21 neuen und 1 gelöschten Zeilen
  1. 21 1
      Service/GearmanClient.php

+ 21 - 1
Service/GearmanClient.php

@@ -68,6 +68,13 @@ class GearmanClient extends AbstractGearmanService
      */
     protected $uniqueJobIdentifierGenerator;
 
+    /**
+     * @var int
+     *
+     * Return code from internal client.
+     */
+    protected $returnCode;
+
     /**
      * Init tasks structure
      *
@@ -225,7 +232,10 @@ class GearmanClient extends AbstractGearmanService
         $gearmanClient = new \GearmanClient();
         $this->assignServers($gearmanClient);
 
-        return $gearmanClient->$method($worker['job']['realCallableName'], $params, $unique);
+        $result = $gearmanClient->$method($worker['job']['realCallableName'], $params, $unique);
+        $this->returnCode = $gearmanClient->returnCode();
+
+        return $result;
     }
 
     /**
@@ -425,6 +435,16 @@ class GearmanClient extends AbstractGearmanService
         return $jobStatus;
     }
 
+    /**
+     * Gets the return code from the last run job.
+     *
+     * @return int
+     */
+    public function getReturnCode()
+    {
+        return $this->returnCode;
+    }
+
     /**
      * Task methods
      */