import { RegisterOptions, PluginList, PluginType, RegistrationInstance } from "../plugins"; import { LoggerOptions } from "../logging"; import { SkeletonClass } from "../skeleton"; declare const kProvider: unique symbol; declare const kServiceToken: unique symbol; declare class RegisterResponse { readonly id: string; private readonly [kProvider]; private readonly [kServiceToken]; constructor(id: string, token: string, provider: Provider); /** * 服务注销 * @returns 是否注销成功 */ unregister(): Promise; /** * 服务心跳上报 * @returns 是否上报成功 */ heartbeat(): Promise; } export declare type ProviderOptions = LoggerOptions; export declare type ProviderPluginList = Pick; export declare class Provider extends SkeletonClass { /** * 当前可实例化的最大次数 */ static get maxInstances(): number; /** * 设置可实例化的最大次数 * @param n 最大次数 */ static setMaxInstances(n: number): void; /** * Create Provider * @param plugins 插件(可选) */ constructor(plugins?: Partial, options?: Partial); /** * 销毁(释放)所占资源 * @param sync 是否同步释放(可选) */ dispose(sync?: boolean): void; /** * 服务注册 * @param namespace 命名空间 * @param service 服务名 * @param token 服务 Token 用来鉴权 * @param instance 待注册的实例 * @param options 注册选项 * @returns 可操作的实例对象(包含注册的实例 `id`) */ register(namespace: string, service: string, token: string, instance: RegistrationInstance, options?: RegisterOptions): Promise; /** * 服务注销 * @param id 实例 ID * @param token 服务 Token 用来鉴权 * @returns 是否注销成功 */ unregister(id: string, token: string): Promise; /** * 服务注销 * @param namespace 命名空间 * @param service 服务名 * @param host 节点 IP 或者域名 * @param port 节点端口号 * @param token 服务 Token 用来鉴权 * @returns 是否注销成功 */ unregister(namespace: string, service: string, host: string, port: number, token: string): Promise; /** * 服务心跳上报 * @param id 实例唯一 ID * @param token 服务 Token 用来鉴权 * @returns 是否发送成功 */ heartbeat(id: string, token: string): Promise; /** * 服务心跳上报 * @param namespace 命名空间 * @param service 服务名 * @param host 节点 IP 或者域名 * @param port 节点端口号 * @param token 服务 Token 用来鉴权 * @returns 是否发送成功 */ heartbeat(namespace: string, service: string, host: string, port: number, token: string): Promise; } export {};