local_topic.go 757 B

1234567891011121314151617181920212223242526272829
  1. package topic
  2. type LocalTopic struct {
  3. Topic
  4. Partitions []*LocalPartition
  5. }
  6. func (localTopic *LocalTopic) findPartition(partition Partition) *LocalPartition {
  7. for _, localPartition := range localTopic.Partitions {
  8. if localPartition.Partition.Equals(partition) {
  9. return localPartition
  10. }
  11. }
  12. return nil
  13. }
  14. func (localTopic *LocalTopic) removePartition(partition Partition) bool {
  15. foundPartitionIndex := -1
  16. for i, localPartition := range localTopic.Partitions {
  17. if localPartition.Partition.Equals(partition) {
  18. foundPartitionIndex = i
  19. break
  20. }
  21. }
  22. if foundPartitionIndex == -1 {
  23. return false
  24. }
  25. localTopic.Partitions = append(localTopic.Partitions[:foundPartitionIndex], localTopic.Partitions[foundPartitionIndex+1:]...)
  26. return true
  27. }