@bililive-tools/douyin-recorder
Version:
@bililive-tools douyin recorder implemention
76 lines (75 loc) • 2.28 kB
TypeScript
import type { APIType, LoadBalancerConfig } from "../types.js";
/**
* 负载均衡器管理工具类
* 提供简化的接口来管理和配置负载均衡器
*/
export declare class LoadBalancerManager {
/**
* 获取所有端点的当前状态
*/
static getStatus(): {
api: APIType;
priority: number;
weight: number;
failureCount: number;
isBlocked: boolean;
lastFailureTime: string;
nextRetryTime: string;
}[];
/**
* 重置指定 API 的状态
*/
static resetAPI(apiType: APIType): void;
/**
* 重置所有 API 的状态
*/
static resetAll(): void;
/**
* 更新 API 端点的配置
*/
static updateAPIConfig(apiType: APIType, config: {
priority?: number;
weight?: number;
}): void;
/**
* 获取负载均衡器配置
*/
static getConfig(): LoadBalancerConfig;
/**
* 更新负载均衡器配置
*/
static updateConfig(config: Partial<LoadBalancerConfig>): void;
/**
* 获取健康的(未被禁用的)API 列表
*/
static getHealthyAPIs(): APIType[];
/**
* 获取被禁用的 API 列表
*/
static getBlockedAPIs(): APIType[];
/**
* 检查特定 API 是否可用
*/
static isAPIHealthy(apiType: APIType): boolean;
/**
* 获取推荐使用的 API(基于当前状态和权重)
*/
static getRecommendedAPI(): APIType | null;
/**
* 打印当前负载均衡器状态(用于调试)
*/
static printStatus(): void;
}
export declare const loadBalancer: {
getStatus: typeof LoadBalancerManager.getStatus;
resetAPI: typeof LoadBalancerManager.resetAPI;
resetAll: typeof LoadBalancerManager.resetAll;
updateAPIConfig: typeof LoadBalancerManager.updateAPIConfig;
getConfig: typeof LoadBalancerManager.getConfig;
updateConfig: typeof LoadBalancerManager.updateConfig;
getHealthyAPIs: typeof LoadBalancerManager.getHealthyAPIs;
getBlockedAPIs: typeof LoadBalancerManager.getBlockedAPIs;
isAPIHealthy: typeof LoadBalancerManager.isAPIHealthy;
getRecommendedAPI: typeof LoadBalancerManager.getRecommendedAPI;
printStatus: typeof LoadBalancerManager.printStatus;
};