فهرست منبع

Added ::getReturnCode to GearmanClient

This wraps the return code from the last created internal client when doEnqueue is executed.
orolin 11 سال پیش
والد
کامیت
7b57568568
1فایلهای تغییر یافته به همراه21 افزوده شده و 1 حذف شده
  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
      */