partition_list.go 982 B

123456789101112131415161718192021222324252627282930313233
  1. package sub_coordinator
  2. import "github.com/seaweedfs/seaweedfs/weed/mq/topic"
  3. type PartitionSlotToConsumerInstance struct {
  4. RangeStart int32
  5. RangeStop int32
  6. UnixTimeNs int64
  7. Broker string
  8. AssignedInstanceId ConsumerGroupInstanceId
  9. FollowerBroker string
  10. }
  11. type PartitionSlotToConsumerInstanceList struct {
  12. PartitionSlots []*PartitionSlotToConsumerInstance
  13. RingSize int32
  14. Version int64
  15. }
  16. func NewPartitionSlotToConsumerInstanceList(ringSize int32, version int64) *PartitionSlotToConsumerInstanceList {
  17. return &PartitionSlotToConsumerInstanceList{
  18. RingSize: ringSize,
  19. Version: version,
  20. }
  21. }
  22. func ToPartitions(ringSize int32, slots []*PartitionSlotToConsumerInstance) []*topic.Partition {
  23. partitions := make([]*topic.Partition, 0, len(slots))
  24. for _, slot := range slots {
  25. partitions = append(partitions, topic.NewPartition(slot.RangeStart, slot.RangeStop, ringSize, slot.UnixTimeNs))
  26. }
  27. return partitions
  28. }