mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
feat: add client availability tracking and error handling improvements
- Introduced `IsAvailable` and `SetUnavailable` methods to clients for availability tracking. - Integrated availability checks in client selection logic to skip unavailable clients. - Enhanced error handling by marking clients unavailable on specific error codes (e.g., 401, 402). - Removed redundant quota verification logs in client reordering logic.
This commit is contained in:
@@ -65,6 +65,7 @@ func NewCodexClient(cfg *config.Config, ts *codex.CodexTokenStorage) (*CodexClie
|
||||
cfg: cfg,
|
||||
modelQuotaExceeded: make(map[string]*time.Time),
|
||||
tokenStorage: ts,
|
||||
isAvailable: true,
|
||||
},
|
||||
codexAuth: codex.NewCodexAuth(cfg),
|
||||
apiKeyIndex: -1,
|
||||
@@ -100,6 +101,7 @@ func NewCodexClientWithKey(cfg *config.Config, apiKeyIndex int) *CodexClient {
|
||||
cfg: cfg,
|
||||
modelQuotaExceeded: make(map[string]*time.Time),
|
||||
tokenStorage: &empty.EmptyStorage{},
|
||||
isAvailable: true,
|
||||
},
|
||||
codexAuth: codex.NewCodexAuth(cfg),
|
||||
apiKeyIndex: apiKeyIndex,
|
||||
@@ -557,3 +559,13 @@ func (c *CodexClient) IsModelQuotaExceeded(model string) bool {
|
||||
func (c *CodexClient) GetRequestMutex() *sync.Mutex {
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsAvailable returns true if the client is available for use.
|
||||
func (c *CodexClient) IsAvailable() bool {
|
||||
return c.isAvailable
|
||||
}
|
||||
|
||||
// SetUnavailable sets the client to unavailable.
|
||||
func (c *CodexClient) SetUnavailable() {
|
||||
c.isAvailable = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user