partition_list.go 938 B

1234567891011121314151617181920212223242526272829303132
  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 string
  9. }
  10. type PartitionSlotToConsumerInstanceList struct {
  11. PartitionSlots []*PartitionSlotToConsumerInstance
  12. RingSize int32
  13. Version int64
  14. }
  15. func NewPartitionSlotToConsumerInstanceList(ringSize int32, version int64) *PartitionSlotToConsumerInstanceList {
  16. return &PartitionSlotToConsumerInstanceList{
  17. RingSize: ringSize,
  18. Version: version,
  19. }
  20. }
  21. func ToPartitions(ringSize int32, slots []*PartitionSlotToConsumerInstance) []*topic.Partition {
  22. partitions := make([]*topic.Partition, 0, len(slots))
  23. for _, slot := range slots {
  24. partitions = append(partitions, topic.NewPartition(slot.RangeStart, slot.RangeStop, ringSize, slot.UnixTimeNs))
  25. }
  26. return partitions
  27. }