下号比率恢复 + 触线降权 + 同步裁决
This commit is contained in:
@@ -32,11 +32,13 @@ class SplitNumberWeighService
|
||||
* @param int $linkId 分流链接 ID
|
||||
* @param int $numberCount 可用号码数量
|
||||
* @param SplitRoundRobinStore $roundRobinStore 关闭随机打乱时的轮转计数器
|
||||
* @param string $poolKey 选号池标识(preferred / deferred 等)
|
||||
*/
|
||||
public static function resolvePickIndex(
|
||||
int $linkId,
|
||||
int $numberCount,
|
||||
SplitRoundRobinStore $roundRobinStore
|
||||
SplitRoundRobinStore $roundRobinStore,
|
||||
string $poolKey = 'main'
|
||||
): int {
|
||||
if ($numberCount <= 0) {
|
||||
return 0;
|
||||
@@ -49,6 +51,26 @@ class SplitNumberWeighService
|
||||
return random_int(0, $numberCount - 1);
|
||||
}
|
||||
|
||||
return $roundRobinStore->nextIndex($linkId, $numberCount);
|
||||
return $roundRobinStore->nextIndex($linkId, $numberCount, $poolKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从号码行列表中按链接配置选一条(严格轮转或随机)
|
||||
*
|
||||
* @param array<int, array<string, mixed>|Number> $rows
|
||||
* @return array<string, mixed>|Number|null
|
||||
*/
|
||||
public static function pickRowFromList(
|
||||
int $linkId,
|
||||
array $rows,
|
||||
SplitRoundRobinStore $roundRobinStore,
|
||||
string $poolKey = 'main'
|
||||
) {
|
||||
$count = count($rows);
|
||||
if ($count === 0) {
|
||||
return null;
|
||||
}
|
||||
$index = self::resolvePickIndex($linkId, $count, $roundRobinStore, $poolKey);
|
||||
return $rows[$index] ?? $rows[0];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user