Example #1
0
 /**
  * setUp
  *
  * @access public
  * @return void
  */
 public function setUp()
 {
     if (is_null($this->stream)) {
         $this->stream = \Kafka\Socket::createFromStream(fopen('php://temp', 'w+b'));
     }
     $this->stream->rewind();
 }
Example #2
0
 /**
  * Read the response error code
  *
  * @return integer Error code
  */
 protected function getResponseCode()
 {
     $this->connect();
     $data = $this->socket->read(2, true);
     $unpack = unpack('n', $data);
     return array_shift($unpack);
 }
Example #3
0
 /**
  * Read the next message 
  *
  * @return string Message (raw)
  * @throws \Kafka\Exception when the message cannot be read from the stream buffer
  */
 protected function getMessage()
 {
     try {
         $size = $this->getMessageSize();
         $msg = $this->socket->read($size, true);
     } catch (Exception\Socket\EOF $e) {
         $size = isset($size) ? $size : 'enough';
         $logMsg = 'Cannot read ' . $size . ' bytes, the message is likely bigger than the buffer - original exception: ' . $e->getMessage();
         throw new Exception\OutOfRange($logMsg);
     }
     $this->validByteCount += 4 + $size;
     return $msg;
 }
Example #4
0
 /**
  * setUp
  *
  * @access public
  * @return void
  */
 public function setUp()
 {
     $this->stream = \Kafka\Socket::createFromStream(fopen('php://temp', 'w+b'));
 }