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
284ce42c
authored
Dec 13, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(channel_select): improve retry logic with reset functionality
parent
ef5e4a05
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
service/channel_select.go
+15
-5
No files found.
service/channel_select.go
View file @
284ce42c
...
...
@@ -12,10 +12,11 @@ import (
)
type
RetryParam
struct
{
Ctx
*
gin
.
Context
TokenGroup
string
ModelName
string
Retry
*
int
Ctx
*
gin
.
Context
TokenGroup
string
ModelName
string
Retry
*
int
resetNextTry
bool
}
func
(
p
*
RetryParam
)
GetRetry
()
int
{
...
...
@@ -30,12 +31,20 @@ func (p *RetryParam) SetRetry(retry int) {
}
func
(
p
*
RetryParam
)
IncreaseRetry
()
{
if
p
.
resetNextTry
{
p
.
resetNextTry
=
false
return
}
if
p
.
Retry
==
nil
{
p
.
Retry
=
new
(
int
)
}
*
p
.
Retry
++
}
func
(
p
*
RetryParam
)
ResetRetryNextTry
()
{
p
.
resetNextTry
=
true
}
// CacheGetRandomSatisfiedChannel tries to get a random channel that satisfies the requirements.
// 尝试获取一个满足要求的随机渠道。
//
...
...
@@ -134,7 +143,8 @@ func CacheGetRandomSatisfiedChannel(param *RetryParam) (*model.Channel, string,
common
.
SetContextKey
(
param
.
Ctx
,
constant
.
ContextKeyAutoGroupIndex
,
i
+
1
)
// Reset retry counter so outer loop can continue for next group
// 重置重试计数器,以便外层循环可以为下一个分组继续
param
.
SetRetry
(
-
1
)
param
.
SetRetry
(
0
)
param
.
ResetRetryNextTry
()
}
else
{
// Stay in current group, save current state
// 保持在当前分组,保存当前状态
...
...
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