12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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>;
- }
|