Ejemplo n.º 1
0
 public function testEncodeDecode64bitLongSigned()
 {
     $long = -2147483648.0;
     $encoded = Kafka_Request::packLong64bigendian($long);
     $this->assertEquals($long, Kafka_Request::unpackLong64bigendian($encoded));
     $long = -2147483649.0;
     $encoded = Kafka_Request::packLong64bigendian($long);
     $this->assertEquals($long, Kafka_Request::unpackLong64bigendian($encoded));
 }
Ejemplo n.º 2
0
 /**
  * Send a request and fetch the response
  *
  * @param Kafka_Request $req Request
  *
  * @return Kafka_MessageSet $messages
  * @throws Kafka_Exception
  */
 public function fetch(Kafka_Request $req)
 {
     $this->connect();
     // send request
     $req->writeTo($this->socket);
     // get response
     $this->lastResponseSize = $this->getResponseSize();
     $responseCode = $this->getResponseCode();
     $initialOffset = 6;
     // validate response
     Kafka_Response::validateErrorCode($responseCode);
     if ($this->lastResponseSize == 2) {
         throw new Kafka_Exception_EmptyQueue();
     }
     return new Kafka_MessageSet($this->socket, $initialOffset);
 }