| 422 | } |
| 423 | |
| 424 | func (r *MetadataResponse) AddTopicPartition(topic string, partition, brokerID int32, replicas, isr []int32, offline []int32, err KError) { |
| 425 | tmatch := r.AddTopic(topic, ErrNoError) |
| 426 | var pmatch *PartitionMetadata |
| 427 | |
| 428 | for _, pm := range tmatch.Partitions { |
| 429 | if pm.ID == partition { |
| 430 | pmatch = pm |
| 431 | goto foundPartition |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | pmatch = new(PartitionMetadata) |
| 436 | pmatch.ID = partition |
| 437 | tmatch.Partitions = append(tmatch.Partitions, pmatch) |
| 438 | |
| 439 | foundPartition: |
| 440 | pmatch.Leader = brokerID |
| 441 | pmatch.Replicas = replicas |
| 442 | if pmatch.Replicas == nil { |
| 443 | pmatch.Replicas = []int32{} |
| 444 | } |
| 445 | pmatch.Isr = isr |
| 446 | if pmatch.Isr == nil { |
| 447 | pmatch.Isr = []int32{} |
| 448 | } |
| 449 | pmatch.OfflineReplicas = offline |
| 450 | if pmatch.OfflineReplicas == nil { |
| 451 | pmatch.OfflineReplicas = []int32{} |
| 452 | } |
| 453 | pmatch.Err = err |
| 454 | } |