Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1.  
  2.     /**
  3.      * Обработка ачивок через worker jobs
  4.      * @param int $loop
  5.      * @param int $loopSleep
  6.      */
  7.     public function actionJobber($loop=0, $loopSleep=5)
  8.     {
  9.         do {
  10.             $queue = $this->module->getQueue();
  11.             $worker = $this->module->getWorker();
  12.  
  13.             $topic = $queue->getTopic(AchievementTopic::class);
  14.             if ($topic) {
  15.                 while ($topic->consume(function($message) use ($worker) {
  16.                     $event = AchievementEvent::createFromMessage($message);
  17.                     $worker->push(new HandleAchievementEventJob(['event' => $event]));
  18.                     return true;
  19.                 }));
  20.  
  21.                 $this->idle($loopSleep);
  22.             } else {
  23.                 $this->stderr("Не подключен топик модуля ачивок" . AchievementTopic::class);
  24.                 return ExitCode::UNSPECIFIED_ERROR;
  25.             }
  26.  
  27.         } while($loop);
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement