/** * set topic partition * * @access public * @return void */ public function setPartition($topicName, $partitionId = 0, $offset = null) { if (is_null($offset)) { if ($this->fromOffset) { $offsetObject = new \Kafka\Offset($this->client, $this->group, $topicName, $partitionId); $offset = $offsetObject->getOffset(\Kafka\Offset::DEFAULT_EARLY); } else { $offset = 0; } } $this->payload[$topicName][$partitionId] = $offset; return $this; }
public function setOffset($topicName, $partitionId, $offset) { $offsetObject = new \Kafka\Offset($this->client, $this->group, $topicName, $partitionId); $offsetObject->setOffset($offset); $this->payload[$topicName][$partitionId] = $offset; }
/** * set topic partition * * @access public * @param $topicName * @param int $partitionId * @param null $offset * @return Consumer */ public function setPartition($topicName, $partitionId = 0, $offset = null) { if (is_null($offset)) { if ($this->fromOffset) { $offsetObject = new \Kafka\Offset($this->client, $this->group, $topicName, $partitionId); $offset = $offsetObject->getOffset($this->offsetStrategy); \Kafka\Log::log('topic name:' . $topicName . ', part:' . $partitionId . 'get offset from kafka server, offet:' . $offset, LOG_DEBUG); } else { $offset = 0; } } $this->payload[$topicName][$partitionId] = $offset; return $this; }
/** * on partition eof call * * @param \Kafka\Protocol\Fetch\Partition $partition * @access public * @return void */ public function onPartitionEof($partition) { $partitionId = $partition->key(); $topicName = $partition->getTopicName(); $offset = $partition->getMessageOffset(); $offsetObject = new \Kafka\Offset($this->client, $this->group, $topicName, $partitionId); $offsetObject->setOffset($offset); }