@inso_web/els-mcp
Version:
MCP-сервер поверх INSO Error Logs Service. Read-only tools (search, analytics, fingerprinting, correlations) для подключения Claude Desktop/Code и ChatGPT к логам ошибок. Streamable HTTP transport + stdio для npx-запуска.
52 lines • 2.26 kB
TypeScript
import type { Redis } from 'ioredis';
import type { Logger } from 'pino';
/**
* Redis singleton-обёртка.
*
* Принципы:
* - Один процесс — один Redis client (singleton).
* - Reconnect strategy: exponential backoff до 10s.
* - Graceful degradation: если Redis недоступен, все методы кэша становятся
* no-op (cache miss → loader fallback). Это решается в `wrapper.ts` —
* здесь только expose флаг `available`.
* - `lazyConnect: true` — соединение поднимается асинхронно, не блокирует startup.
*/
export interface RedisServiceOptions {
url: string;
log?: Logger;
/** Принудительно использовать готовый client (для тестов с ioredis-mock). */
client?: Redis;
/** Disable cache entirely (graceful no-op). */
disabled?: boolean;
}
export declare class RedisService {
private readonly client;
private readonly log;
private connected;
private readonly disabled;
constructor(opts: RedisServiceOptions);
private attachListeners;
/** True если Redis недоступен или disabled. */
get unavailable(): boolean;
get raw(): Redis | null;
/**
* Безопасный GET, возвращает null при любых ошибках/недоступности.
*/
get(key: string): Promise<string | null>;
/**
* Безопасный SETEX. Возвращает true если записали, false при ошибке.
*/
setex(key: string, ttlSec: number, value: string): Promise<boolean>;
/** Health-check (ping → PONG). Возвращает true если ответил. */
ping(): Promise<boolean>;
close(): Promise<void>;
}
/**
* Получить (или создать) singleton экземпляр.
*
* В тестах используем `setRedisServiceForTests(...)`.
*/
export declare function getRedisService(opts?: RedisServiceOptions): RedisService;
export declare function setRedisServiceForTests(service: RedisService | null): void;
export declare function resetRedisSingleton(): void;
//# sourceMappingURL=redis.d.ts.map