feat(ProviderPoolManager): 添加健康检查跳过逻辑和重置健康状态方法
添加markProviderZero方法用于重置提供商的错误计数和使用计数 当健康检查未实现时跳过检查并自动标记为零状态 优化健康检查返回null时的处理逻辑
This commit is contained in:
parent
0d9e01d137
commit
f07d1361c8
1 changed files with 26 additions and 1 deletions
|
|
@ -139,6 +139,26 @@ export class ProviderPoolManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a provider as healthy.
|
||||
* @param {string} providerType - The type of the provider.
|
||||
* @param {object} providerConfig - The configuration of the provider to mark.
|
||||
*/
|
||||
markProviderZero(providerType, providerConfig) {
|
||||
const pool = this.providerStatus[providerType];
|
||||
if (pool) {
|
||||
const provider = pool.find(p => p.uuid === providerConfig.uuid);
|
||||
if (provider) {
|
||||
provider.config.errorCount = 0; // Reset error count on health recovery
|
||||
provider.config.usageCount = 0; // Reset usage count on health recovery
|
||||
console.log(`[ProviderPoolManager] Marked provider as zero: ${provider.config.uuid} for type ${providerType}`);
|
||||
|
||||
// 优化1: 使用防抖保存
|
||||
this._debouncedSave(providerType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用指定提供商
|
||||
* @param {string} providerType - 提供商类型
|
||||
|
|
@ -198,6 +218,11 @@ export class ProviderPoolManager {
|
|||
try {
|
||||
// Perform actual health check based on provider type
|
||||
const isHealthy = await this._checkProviderHealth(providerType, providerConfig);
|
||||
if(isHealthy === null){
|
||||
console.log(`[ProviderPoolManager] Health check for ${providerConfig.uuid} (${providerType}) skipped: Check not implemented.`);
|
||||
this.markProviderZero(providerType, providerConfig);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isHealthy) {
|
||||
if (!providerStatus.config.isHealthy) {
|
||||
|
|
@ -246,7 +271,7 @@ export class ProviderPoolManager {
|
|||
};
|
||||
const serviceAdapter = getServiceAdapter(tempConfig);
|
||||
if(!providerConfig.checkHealth){
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Determine a suitable model name for health check
|
||||
|
|
|
|||
Loading…
Reference in a new issue