fix(failover): improve cache cleanup for provider health and circuit breaker

- Use removeQueries instead of invalidateQueries when stopping proxy to
  completely clear health and circuit breaker caches
- Clear provider health and circuit breaker caches when removing from
  failover queue
- Refresh failover queue after drag-sort since queue order depends on
  sort_index
- Only show health badge when provider is in failover queue
This commit is contained in:
YoVinchen
2025-12-22 23:48:56 +08:00
parent 2c18e125dc
commit f5f7ab7ce2
4 changed files with 24 additions and 4 deletions
+5
View File
@@ -75,6 +75,11 @@ export function useDragSort(providers: Record<string, Provider>, appId: AppId) {
queryKey: ["providers", appId],
});
// 刷新故障转移队列(因为队列顺序依赖 sort_index
await queryClient.invalidateQueries({
queryKey: ["failoverQueue", appId],
});
// 更新托盘菜单以反映新的排序(失败不影响主操作)
try {
await providersApi.updateTrayMenu();
+4 -2
View File
@@ -73,8 +73,10 @@ export function useProxyStatus() {
);
queryClient.invalidateQueries({ queryKey: ["proxyStatus"] });
queryClient.invalidateQueries({ queryKey: ["proxyTakeoverStatus"] });
// 除所有供应商健康状态缓存(后端已清空数据库记录)
queryClient.invalidateQueries({ queryKey: ["providerHealth"] });
// 彻底删除所有供应商健康状态缓存(后端已清空数据库记录)
queryClient.removeQueries({ queryKey: ["providerHealth"] });
// 彻底删除所有熔断器统计缓存(代理停止后熔断器状态已重置)
queryClient.removeQueries({ queryKey: ["circuitBreakerStats"] });
// 注意:故障转移队列和开关状态会保留,不需要刷新
},
onError: (error: Error) => {