1808837298@qq.com 2 лет назад
Родитель
Сommit
06b746a740
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      model/cache.go

+ 5 - 5
model/cache.go

@@ -291,19 +291,19 @@ func CacheGetRandomSatisfiedChannel(group string, model string) (*Channel, error
 			}
 		}
 	}
+
 	// 平滑系数
 	smoothingFactor := 10
-
 	// Calculate the total weight of all channels up to endIdx
 	totalWeight := 0
 	for _, channel := range channels[:endIdx] {
 		totalWeight += channel.GetWeight() + smoothingFactor
 	}
 
-	if totalWeight == 0 {
-		// If all weights are 0, select a channel randomly
-		return channels[rand.Intn(endIdx)], nil
-	}
+	//if totalWeight == 0 {
+	//	// If all weights are 0, select a channel randomly
+	//	return channels[rand.Intn(endIdx)], nil
+	//}
 
 	// Generate a random value in the range [0, totalWeight)
 	randomWeight := rand.Intn(totalWeight)