Exemple #1
0
 public static function serialize(Result $result)
 {
     $cloned = clone $result;
     $serializedTask = TaskFormatter::serialize($cloned->getTask());
     $serializedFork = ForkFormatter::serialize($cloned->getFork());
     $cloned->setTask(null);
     $cloned->setFork(null);
     return serialize(array('serializedTask' => $serializedTask, 'serializedFork' => $serializedFork, 'result' => $cloned));
 }
Exemple #2
0
 /**
  * @param   \Ackintosh\Snidel\Task  $task
  * @return  void
  * @throws  RuntimeException
  */
 public function enqueue($task)
 {
     $this->queuedCount++;
     $serialized = Formatter::serialize($task);
     if ($this->isExceedsLimit($serialized)) {
         throw new \RuntimeException('the task exceeds the message queue limit.');
     }
     if (!$this->sendMessage($serialized)) {
         throw new \RuntimeException('failed to enqueue task.');
     }
 }