public function loadNextPartition()
{
if ($this->validCount >= $this->partitionCount) {
return false;
}
try {
$partitionId = $this->stream->read(4, true);
$partitionId = Decoder::unpack(Decoder::BIT_B32, $partitionId);
$partitionId = array_shift($partitionId);
\Kafka\Log::log("kafka client:fetch partition:" . $partitionId, LOG_INFO);
$errCode = $this->stream->read(2, true);
$errCode = Decoder::unpack(Decoder::BIT_B16, $errCode);
$this->errCode = array_shift($errCode);
if ($this->errCode != 0) {
throw new \Kafka\Exception(\Kafka\Protocol\Decoder::getError($this->errCode));
}
$offset = $this->stream->read(8, true);
$this->offset = \Kafka\Protocol\Decoder::unpack(Decoder::BIT_B64, $offset);
$this->key = $partitionId;
$this->current = new MessageSet($this, $this->context);
} catch (\Kafka\Exception $e) {
\Kafka\Log::log($e->getMessage(), LOG_ERR);
return false;
}
$this->validCount++;
return true;
}