예제 #1
0
 /**
  * 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;
 }
예제 #2
0
 public function setOffset($topicName, $partitionId, $offset)
 {
     $offsetObject = new \Kafka\Offset($this->client, $this->group, $topicName, $partitionId);
     $offsetObject->setOffset($offset);
     $this->payload[$topicName][$partitionId] = $offset;
 }
예제 #3
0
 /**
  * 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;
 }
예제 #4
0
 /**
  * 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);
 }