MCPcopy
hub / github.com/segmentio/kafka-go / readTopicMetadatav1

Method readTopicMetadatav1

conn.go:1032–1052  ·  view source on GitHub ↗
(brokers map[int32]Broker, topicMetadata []topicMetadataV1)

Source from the content-addressed store, hash-verified

1030}
1031
1032func (c *Conn) readTopicMetadatav1(brokers map[int32]Broker, topicMetadata []topicMetadataV1) (partitions []Partition, err error) {
1033 for _, t := range topicMetadata {
1034 if t.TopicErrorCode != 0 && (c.topic == "" || t.TopicName == c.topic) {
1035 // We only report errors if they happened for the topic of
1036 // the connection, otherwise the topic will simply have no
1037 // partitions in the result set.
1038 return nil, Error(t.TopicErrorCode)
1039 }
1040 for _, p := range t.Partitions {
1041 partitions = append(partitions, Partition{
1042 Topic: t.TopicName,
1043 Leader: brokers[p.Leader],
1044 Replicas: makeBrokers(brokers, p.Replicas...),
1045 Isr: makeBrokers(brokers, p.Isr...),
1046 ID: int(p.PartitionID),
1047 OfflineReplicas: []Broker{},
1048 })
1049 }
1050 }
1051 return
1052}
1053
1054func (c *Conn) readTopicMetadatav6(brokers map[int32]Broker, topicMetadata []topicMetadataV6) (partitions []Partition, err error) {
1055 for _, t := range topicMetadata {

Callers 1

Calls 2

makeBrokersFunction · 0.85
ErrorTypeAlias · 0.70

Tested by

no test coverage detected