2025-04-02 21:57:33 +08:00

65 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { InternalConfig } from './base';
export declare class Host {
host: string;
protocol: InternalConfig['upprotocol'];
constructor(host: string, protocol: InternalConfig['upprotocol']);
/**
* @description 当前 host 是否为冻结状态
*/
isFrozen(): boolean;
/**
* @param {number} time 单位秒,默认 20s
* @description 冻结该 host 对象,该 host 将在指定时间内不可用
*/
freeze(time?: number): void;
/**
* @description 解冻该 host
*/
unfreeze(): void;
/**
* @description 获取当前 host 的完整 url
*/
getUrl(): string;
/**
* @description 获取解冻时间
*/
getUnfreezeTime(): number | undefined;
}
export declare class HostPool {
private initHosts;
/**
* @description 缓存的 host 表,以 bucket 和 accessKey 作为 key
*/
private cachedHostsMap;
/**
* @param {string[]} initHosts
* @description 如果在构造时传入 initHosts则该 host 池始终使用传入的 initHosts 做为可用的数据
*/
constructor(initHosts?: string[]);
/**
* @param {string} accessKey
* @param {string} bucketName
* @param {string[]} hosts
* @param {InternalConfig['upprotocol']} protocol
* @returns {void}
* @description 注册可用 host
*/
private register;
/**
* @param {string} accessKey
* @param {string} bucketName
* @param {InternalConfig['upprotocol']} protocol
* @returns {Promise<void>}
* @description 刷新最新的 host 数据,如果用户在构造时该类时传入了 host 或者已经存在缓存则不会发起请求
*/
private refresh;
/**
* @param {string} accessKey
* @param {string} bucketName
* @param {InternalConfig['upprotocol']} protocol
* @returns {Promise<Host | null>}
* @description 获取一个可用的上传 Host排除已冻结的
*/
getUp(accessKey: string, bucketName: string, protocol: InternalConfig['upprotocol']): Promise<Host | null>;
}