You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
757 B

  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. }