func()

in store/cluster.go [179:196]


func (cluster *Cluster) findShardIndexBySlot(slot SlotRange) (int, error) {
	sourceShardIdx := -1
	for i := 0; i < len(cluster.Shards); i++ {
		slotRanges := cluster.Shards[i].SlotRanges
		for _, slotRange := range slotRanges {
			if slotRange.HasOverlap(&slot) {
				if sourceShardIdx != -1 {
					return sourceShardIdx, consts.ErrSlotRangeBelongsToMultipleShards
				}
				sourceShardIdx = i
			}
		}
	}
	if sourceShardIdx == -1 {
		return -1, consts.ErrSlotNotBelongToAnyShard
	}
	return sourceShardIdx, nil
}