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