Kafka\ZooKeeper::getConsumersPerTopic PHP Method

getConsumersPerTopic() public method

get consumer per topic
public getConsumersPerTopic ( string $groupId ) : array
$groupId string
return array
    public function getConsumersPerTopic($groupId)
    {
        $consumers = $this->listConsumer($groupId);
        if (empty($consumers)) {
            return array();
        }
        $topics = array();
        foreach ($consumers as $consumerId) {
            $path = sprintf(self::REG_CONSUMER, (string) $groupId) . '/' . $consumerId;
            if (!$this->zookeeper->exists($path)) {
                continue;
            }
            $info = $this->zookeeper->get($path);
            $info = json_decode($info, true);
            $subTopic = isset($info['subscription']) ? $info['subscription'] : array();
            foreach ($subTopic as $topic => $num) {
                $topics[$topic] = $consumerId;
            }
        }
        return $topics;
    }