public function testQueue() { $client = new Client(self::PORT); $client->queue('test')->push(1); $client->queue('test')->push(2); $client->queue('test')->push(3); $this->assertEquals(1, $client->queue('test')->pop()); $this->assertEquals(2, $client->queue('test')->pop()); $this->assertEquals(3, $client->queue('test')->pop()); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $serverName = $input->getOption('server'); list($host, $port) = explode(':', $input->getOption('master')); $pure = new Client($port, $host); try { $server = $this->deployer->servers->get($serverName); $environment = isset($this->deployer->environments[$serverName]) ? $this->deployer->environments[$serverName] : new Environment(); $output = new RemoteOutput($output, $pure, $serverName); while ($pure->ping()) { // Get task to do $taskName = $pure->map('tasks_to_do')->get($serverName); if (null !== $taskName) { $task = $this->deployer->tasks->get($taskName); try { $task->run(new Context($server, $environment, $input, $output)); } catch (NonFatalException $e) { $pure->queue('exception')->push([$serverName, get_class($e), $e->getMessage()]); } $pure->map('tasks_to_do')->delete($serverName); } } } catch (\Exception $exception) { $pure->queue('exception')->push([$serverName, get_class($exception), $exception->getMessage()]); } }
/** * {@inheritdoc} */ public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL) { $this->pure->queue('output')->push([$this->server, $messages, $newline, $type]); }