Пример #1
0
 /**
  * @return Tube[]
  * @throws Exception\InvalidArgumentException
  */
 public function tubes()
 {
     $tubes = [];
     foreach ($this->server->dispatchCommand($this->commandFactory->create(CommandInterface::COMMAND_LIST_TUBES))->invoke()->getData() as $tubeName) {
         $tubes[] = new Tube($tubeName, $this->server);
     }
     return $tubes;
 }
Пример #2
0
 /**
  * @param string[] $tubes
  * @param string[] $otherTubes
  * @param string $command
  * @return CommandInterface[]
  * @throws \Beanie\Exception\InvalidArgumentException
  */
 protected function calculateDiffTubes($tubes, $otherTubes, $command)
 {
     $commands = [];
     foreach (array_diff($tubes, $otherTubes) as $tube) {
         $commands[] = $this->commandFactory->create($command, [$tube]);
     }
     return $commands;
 }
Пример #3
0
 public function testWatchCommand_ParseResponse_returnsResponse()
 {
     $responseLine = sprintf('%s %s', Response::RESPONSE_WATCHING, 1);
     $watchCommand = $this->commandFactory->create(CommandInterface::COMMAND_WATCH, [Beanie::DEFAULT_TUBE]);
     $response = $watchCommand->parseResponse($responseLine, $this->getServerMock());
     $this->assertEquals(Response::RESPONSE_WATCHING, $response->getName());
     $this->assertEquals(1, $response->getData());
     $this->assertEquals($this->getServerMock(), $response->getServer());
 }
Пример #4
0
 /**
  * @param string $command
  * @param array $arguments
  * @return Response
  */
 private function executeCommand($command, $arguments = [])
 {
     return $this->server->dispatchCommand($this->commandFactory->create($command, $arguments))->invoke();
 }
Пример #5
0
 /**
  * @return JobOath
  * @throws Exception\InvalidArgumentException
  */
 public function reserveOath()
 {
     return $this->jobFactory->createFromCommand($this->commandFactory->create(CommandInterface::COMMAND_RESERVE), $this->server->transformTubeStatusTo($this->getTubeStatus(), TubeStatus::TRANSFORM_WATCHED));
 }
Пример #6
0
 /**
  * @param string $jobData
  * @param int $priority
  * @param int $delay
  * @param int $timeToRun
  * @return Job
  * @throws Exception\InvalidArgumentException
  */
 public function put($jobData, $priority = Beanie::DEFAULT_PRIORITY, $delay = Beanie::DEFAULT_DELAY, $timeToRun = Beanie::DEFAULT_TIME_TO_RUN)
 {
     return $this->createJob($jobData, $this->pool->transformTubeStatusTo($this->tubeStatus)->dispatchCommand($this->commandFactory->create(CommandInterface::COMMAND_PUT, [$jobData, $priority, $delay, $timeToRun]))->invoke());
 }