@nexe/config-manager
Version:
Nexe Config Manager - A flexible configuration management solution with multiple sources and hot reload support
79 lines • 1.75 kB
TypeScript
import type { IConfigSource } from '../interfaces';
interface ConsulOptions {
host: string;
port: number;
secure?: boolean;
token?: string;
dc?: string;
defaultKeyPrefix?: string;
}
/**
* 支持动态路径的 Consul 配置源
* 允许在运行时指定不同的配置路径前缀
*/
export declare class ConsulConfigSource implements IConfigSource {
private consul;
private options;
private pathCaches;
private callbacks;
private watchers;
private recreatingWatchers;
/**
* @param options Consul配置选项
*/
constructor(options: ConsulOptions);
/**
* 从Consul加载配置
*/
load(key?: string, pathPrefix?: string): Promise<unknown>;
/**
* 获取指定前缀的所有配置键
*/
private fetchKeysForPrefix;
/**
* 获取相对路径
*/
private getRelativePath;
/**
* 解码Consul值
*/
private decodeConsulValue;
/**
* 获取嵌套值
*/
private getNestedValue;
/**
* 设置嵌套值
*/
private setNestedValue;
/**
* 获取配置源名称
*/
getName(): string;
/**
* 是否支持热更新
*/
supportsHotReload(): boolean;
/**
* 是否支持动态路径
*/
supportsDynamicPath(): boolean;
/**
* 订阅配置变更
*/
subscribe(key: string, callback: (value: unknown) => void, pathPrefix?: string): void;
/**
* 取消订阅配置变更
*/
unsubscribe(key: string, pathPrefix?: string): void;
/**
* 创建配置监听器
*/
private createWatcher;
/**
* 清理资源
*/
dispose(): void;
}
export {};
//# sourceMappingURL=consul-config-source.d.ts.map