@yuntools/ali-alb
Version:
阿里云 ALB 负载均衡模块封装,支持 ESM,CJS 导入,提供 TypeScript 类型定义
80 lines • 3.37 kB
TypeScript
import Alb, { UpdateServerGroupServersAttributeResponseBody, ListServerGroupsResponseBodyServerGroups, ListAsynJobsResponseBodyJobs } from '@alicloud/alb20200616';
import { EcsClient } from '@yuntools/ali-ecs';
import { ActionRet, CalcuWeightOptions, GroupServer, JobStatus, ServerGroupId, UpdateServerWeightOptions } from './types.js';
/** 阿里云 ALB 负载均衡服务接口 */
export declare class AlbClient {
protected id: string;
protected secret: string;
endpoint: string;
ecsClientInstance?: EcsClient | undefined;
/**
* 是否输出日志
* @default false
*/
debug: boolean;
/**
* 是否输出渐进日志
* @default true
*/
showProgressLog: boolean;
client: Alb;
nextToken: string;
ecsClient: EcsClient;
groupServersCache: Map<string, import("@alicloud/alb20200616").ListServerGroupServersResponseBodyServers[]>;
cacheTime: number;
cacheTTLSec: number;
constructor(id: string, secret: string, endpoint?: string, ecsClientInstance?: EcsClient | undefined);
/**
* 获取指定服务组信息
*/
getGroup(serverGroupId: string): Promise<ListServerGroupsResponseBodyServerGroups | undefined>;
/**
* 获取指定服务组指定服务器信息
*/
getGroupServer(serverGroupId: string, serverId: string, withoutCache?: boolean): Promise<GroupServer | undefined>;
/**
* 根据公网 IPs 获取指定服务组指定服务器信息
*/
getGroupServerByPublicIps(serverGroupId: string, ips: string[]): Promise<Map<string, GroupServer>>;
/**
* 根据公网 IP 获取指定服务组指定服务器信息
*/
getGroupServerByPublicIp(serverGroupId: string, ip: string): Promise<GroupServer | undefined>;
/**
* 列出指定服务器组的服务器列表信息
*/
listGroupServers(serverGroupId: string): Promise<GroupServer[] | undefined>;
/**
* 获取异步任务信息
*/
getJobInfo(jobId: string): Promise<ListAsynJobsResponseBodyJobs | undefined>;
/**
* 渐进更新指定服务器的权重到指定值,
* 直到异步任务状态为 Succeeded 或 Failed,
* 并返回异步任务信息和服务器信息
*/
updateServerWeightByPublicIp(options: UpdateServerWeightOptions): Promise<ActionRet | undefined>;
/**
* 渐进更新指定服务器的权重到指定值,
* 直到异步任务状态为 Succeeded 或 Failed,
* 并返回异步任务信息和服务器信息
*/
updateServerWeight(options: UpdateServerWeightOptions): Promise<ActionRet | undefined>;
/**
* 设置服务器组的权重属性
*/
setServersWeight(serverGroupId: string, serverIds: string[], weight: number): Promise<UpdateServerGroupServersAttributeResponseBody>;
/**
* 查询指定任务的状态是否匹配输入的状态值
*/
isJobMatchStatusList<T extends JobStatus>(jobId: string, statusArray: T[]): Promise<T | false>;
cleanCache(force?: boolean): void;
updateCache(groupId: ServerGroupId, servers: GroupServer[] | undefined): void;
private _cleanCache;
private loopServerUntilWeight;
private loopJobUntilStatuses;
private createClient;
}
export declare function caculateWeights(options: CalcuWeightOptions): number[];
/** serverId -> GroupServer */
//# sourceMappingURL=alb.d.ts.map