import { SkeletonClass } from "../skeleton"; import { PluginType, PluginList } from "../plugins"; import { RatelimitOptions, Quota } from "./ratelimit"; import { LoggerOptions } from "../logging"; import { Metadata } from "../metadata"; import { LocalRegistryOptions } from "../registry"; export declare type LimiterPluginList = Pick; export declare type LimiterOptions = RatelimitOptions & LoggerOptions & LocalRegistryOptions; export interface AcquireResponse { /** * 唯一 ID * 用于优化下次查询性能 */ readonly id?: string; /** * 配额 */ readonly quotas: Quota[]; } declare const kRatelimit: unique symbol; declare const kRegistry: unique symbol; export declare class Limiter extends SkeletonClass { /** * 当前可实例化的最大次数 */ static get maxInstances(): number; /** * 设置可实例化的最大次数 * @param n 最大次数 */ static setMaxInstances(n: number): void; private readonly [kRatelimit]; private readonly [kRegistry]; /** * Create Limiter * @param plugins 插件(可选) * @param options 配置参数(可选) */ constructor(plugins?: Partial, options?: Partial); /** * 销毁(释放)所占资源 * * @description * dispose order: * Ratelimit -> Registry -> [plguins] * * @param sync 是否同步释放(可选) */ dispose(sync?: boolean): void; /** * 通过条件获取配额分配对象 * @param namespace 命名空间 * @param service 服务名 * @param amount 请求的配额数 * @param cluster 集群名(可选) * @param labels 标签集合(可选) * @param id 唯一 ID(可选) */ acquire(namespace: string, service: string, amount: number, cluster?: string, labels?: Metadata, id?: string): Promise; } export {};