コード例 #1
0
 public function handleComplete(\GearmanTask $task)
 {
     /**
      * @var ExecutionDto $taskData
      */
     $taskData = @unserialize($task->data());
     try {
         $this->tasksInspector->checkTaskDataType($taskData);
         if (!$taskData->isErrorExist()) {
             $this->tasksInspector->unsetCreatedTask($taskData->getTaskId());
             $this->tasksInspector->incrementCorrectlyExecuted();
         } else {
             if ($taskData->isCriticalError()) {
                 $this->logger->critical($taskData->getErrorMessage());
                 $this->tasksInspector->setExecutedWithError($taskData);
                 $this->tasksInspector->inspect();
                 die;
             } else {
                 $this->tasksInspector->setExecutedWithError($taskData);
             }
         }
     } catch (\Exception $e) {
         $this->logger->error($e->getMessage() . $this->loggerPostfix);
     }
     $this->logger->notice("COMPLETE: " . $task->jobHandle() . ", " . serialize($taskData));
     return null;
 }
コード例 #2
0
 public function _onTask(\GearmanTask $task)
 {
     $data = GearmanToolsUtils::unpackMessage($task->data());
     $url = $data['url'];
     $extractedUrls = $data['extractedUrls'];
     $error = $data['error'];
     $message = $data['message'];
     // add extracted url
     foreach ($extractedUrls as $extractedUrl) {
         $this->repository->insert($extractedUrl);
     }
     // log
     if ($error === 0) {
         $this->logger->info($message);
     } else {
         $this->logger->error($message);
     }
     // mark Url as processed
     $this->repository->done($url);
 }
コード例 #3
0
ファイル: gearman.php プロジェクト: samsoir/vitesse
 /**
  * Handles completed task event called by the Gearman client,
  * parses the response object and assigns it to the request.
  *
  * @param   GearmanTask $task 
  * @return  void
  */
 protected function _task_data(GearmanTask $task)
 {
     try {
         // Assign the response to the request
         $this->_request[$task->unique()]->response = unserialize($task->data());
     } catch (Exception $e) {
         $this->_task_exception($task, $e);
     }
 }