コード例 #1
0
 /**
  * @throws \React\PublisherPulsar\Inventory\Exceptions\PublisherPulsarException
  */
 public function testWaitAllowingSubscriptionMessage()
 {
     sleep(2);
     self::$performer->waitAllowingSubscriptionMessage();
     $this->assertInstanceOf(\React\PublisherPulsar\Inventory\PublisherToSubscribersDto::class, self::$performer->getPublisherToSubscribersDto());
 }
コード例 #2
0
ファイル: Pulsar.php プロジェクト: jamset/publisher-pulsar
 /**
  * @return null
  * @throws PublisherPulsarException
  */
 protected function initPerformerImitator()
 {
     $this->logger->debug("Performer imitator start work.");
     if (!$this->performerImitator) {
         $this->performerImitator = new Performer();
         $performerDto = new PerformerDto();
         $performerDto->setLogger($this->logger);
         $performerDto->setModuleName(PerformerConstants::PERFORMER_IMITATOR);
         $performerSocketParams = new PerformerSocketsParamsDto();
         $performerSocketParams->setRequestPulsarRsSocketAddress($this->pulsarSocketsParams->getReplyStackSocketAddress());
         $performerDto->setSocketsParams($performerSocketParams);
         $this->performerImitator->setPerformerDto($performerDto);
     }
     $sendStatuses = [];
     $requestsNumber = 0;
     //balance between needed to go further and the activity of real performers
     while (count($sendStatuses) < $this->shouldBeSubscribersNumber - $this->iAmSubscriber && $requestsNumber < $this->shouldBeSubscribersNumber + $this->shouldBeSubscribersNumber * 0.5) {
         sleep(1);
         $sendStatus = $this->performerImitator->requestForActionPermission("don't wait");
         if ($sendStatus) {
             $sendStatuses[] = $sendStatus;
             $this->performerImitationRequests++;
             $this->logger->debug("Performer imitator send success imitation request: " . $this->performerImitationRequests);
         }
         $requestsNumber++;
     }
     $this->logger->debug("Performer imitator finish work.");
     $this->performerImitatorActive = false;
     return null;
 }