Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
93edde59
authored
Oct 29, 2025
by
creamlike1024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 当totalWeight小于等于0时设置为1选择第一个渠道
parent
b26333b2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
model/channel_cache.go
+5
-0
No files found.
model/channel_cache.go
View file @
93edde59
...
@@ -166,6 +166,11 @@ func GetRandomSatisfiedChannel(group string, model string, retry int) (*Channel,
...
@@ -166,6 +166,11 @@ func GetRandomSatisfiedChannel(group string, model string, retry int) (*Channel,
}
}
// Calculate the total weight of all channels up to endIdx
// Calculate the total weight of all channels up to endIdx
totalWeight
:=
sumWeight
*
smoothingFactor
totalWeight
:=
sumWeight
*
smoothingFactor
// totalWeight 小于等于0时,设置为1,选择第一个渠道
if
totalWeight
<=
0
{
totalWeight
=
1
}
// Generate a random value in the range [0, totalWeight)
// Generate a random value in the range [0, totalWeight)
randomWeight
:=
rand
.
Intn
(
totalWeight
)
randomWeight
:=
rand
.
Intn
(
totalWeight
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment