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;
 }
Exemple #2
0
 public function task()
 {
     $config = $this->config->item('base_config');
     $host = $config['gearman']['host'];
     $port = $config['gearman']['port'];
     $task = new GearmanTask();
     var_dump($task->taskDenominator());
     var_dump($task->taskNumerator());
 }
 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);
 }
Exemple #4
0
 function taskFail(\GearmanTask $task)
 {
     error_log('taskFail: ' . $task->jobHandle());
 }
Exemple #5
0
	/**
	 * Callback for getting updated status infromation from a worker
	 *
	 * @param GearmanTask $task
	 **/
	public function reverse_status($task)
	{
	    echo "STATUS: " . $task->jobHandle() . " - " . $task->taskNumerator() . 
	         "/" . $task->taskDenominator() . "\n";
	}
Exemple #6
-1
 /**
  * Handles exceptions thrown by Kohana and Gearman client, setting the
  * errors array as appropriate
  *
  * @param GearmanTask $task 
  * @param Exception $exception 
  * @return void
  * @author Sam de Freyssinet
  */
 protected function _task_exception(GearmanTask $task, Exception $exception = NULL)
 {
     $uuid = $task->unique();
     $error = $exception === NULL;
     $this->errors[$uuid] = array('type' => $error ? 'error' : 'exception', 'errorNo' => $error ? $this->_gearman_client->getErrno() : $exception->getCode(), 'error' => $error ? $this->_gearman_client->error() : $exception);
 }