mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 04:10:51 +08:00
feat: add fill-first routing strategy
This commit is contained in:
@@ -5,6 +5,7 @@ package cliproxy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/api"
|
||||
sdkaccess "github.com/router-for-me/CLIProxyAPI/v6/sdk/access"
|
||||
@@ -197,7 +198,20 @@ func (b *Builder) Build() (*Service, error) {
|
||||
if dirSetter, ok := tokenStore.(interface{ SetBaseDir(string) }); ok && b.cfg != nil {
|
||||
dirSetter.SetBaseDir(b.cfg.AuthDir)
|
||||
}
|
||||
coreManager = coreauth.NewManager(tokenStore, nil, nil)
|
||||
|
||||
strategy := ""
|
||||
if b.cfg != nil {
|
||||
strategy = strings.ToLower(strings.TrimSpace(b.cfg.Routing.Strategy))
|
||||
}
|
||||
var selector coreauth.Selector
|
||||
switch strategy {
|
||||
case "round-robin", "roundrobin", "rr":
|
||||
selector = &coreauth.RoundRobinSelector{}
|
||||
default:
|
||||
selector = &coreauth.FillFirstSelector{}
|
||||
}
|
||||
|
||||
coreManager = coreauth.NewManager(tokenStore, selector, nil)
|
||||
}
|
||||
// Attach a default RoundTripper provider so providers can opt-in per-auth transports.
|
||||
coreManager.SetRoundTripperProvider(newDefaultRoundTripperProvider())
|
||||
|
||||
Reference in New Issue
Block a user