Kafka\ZooKeeper::registerConsumer PHP Method

registerConsumer() public method

register consumer
public registerConsumer ( $groupId, integer $consumerId, array $topics = [] )
$groupId
$consumerId integer
$topics array
    public function registerConsumer($groupId, $consumerId, $topics = array())
    {
        if (empty($topics)) {
            return;
        }
        $path = sprintf(self::REG_CONSUMER, (string) $groupId);
        $subData = array();
        foreach ($topics as $topic) {
            $subData[$topic] = 1;
        }
        $data = array('version' => '1', 'pattern' => 'white_list', 'subscription' => $subData);
        if (!$this->zookeeper->exists($path)) {
            $this->makeZkPath($path);
        }
        $consumerPath = $path . '/' . $consumerId;
        if (!$this->zookeeper->exists($consumerPath)) {
            $this->makeZkPath($consumerPath);
            $this->makeZkNode($consumerPath, json_encode($data), \ZooKeeper::EPHEMERAL);
        } else {
            $this->zookeeper->set($consumerPath, json_encode($data));
        }
        //var_dump($this->zookeeper->getChildren($path));
    }