/** * B1(鲁棒性批3 立案的设计件):/health 活体 store 探测的后台缓存环。 * * 为什么是缓存环而不是逐请求探:/health 是 fleet center/k8s 的高频面(10-15s 一拍×N 消费方), * 逐请求打 DB 会把健康检查本身变成负载源、且慢 store 直接拖垮 /health 的「必须回答此刻」承诺。 * 环产出的 state 由 /health 的 additive 键族消费(座注见 http/server.ts `storeLiveState`; * 键形钉在 test/health-store-live.test.ts,本环判据钉在 test/store-live-probe.test.ts)。 * * 判据: * - 有界:单拍探针经 STORE_PROBE_TIMEOUT_MS race——挂死的 pool(半开连接)不得卡住环; * - 翻转披露(§M):live→dead warn `store_probe_dead`、dead→live info `store_probe_recovered`, * 只在翻转拍记(连续死不逐拍刷日志——down 的 DB 不该制造日志风暴); * - 诚实缺席:首拍落地前 state() = undefined(/health 键缺席=「还没探过」,不冒充「活」)。 * - 面分级([ref]):`state().error` 是**原始** message —— 它只喂给凭证后/本机的消费面;免鉴权的 * `/health` 一格由 wire 装配点过 {@link publicStoreProbeError} 换成闭集词(理由见该常量头注)。 * * 探针原语:调用方给 `probe`(main.ts 传 `() => backend.dbNowMs!()`——既有 S10 时钟探针的真 DB * 往返,零新 SQL 面)。timer 全部 unref(环不得阻止进程退出)。 */ /** 单拍探针上界——挂死连接的判死时间;3s 对 15s 默认间隔留足余量(环内串行,无叠拍)。 */ export declare const STORE_PROBE_TIMEOUT_MS = 3000; export interface StoreLiveState { live: boolean; /** 距上一次探针**落地**(成功或失败)的毫秒——消费方判「这份缓存多旧」。 */ ageMs: number; error?: string; } export interface StoreLiveProbe { /** /health 读座:undefined = 首拍未落地。 */ state: () => StoreLiveState | undefined; stop: () => void; } /** * [ref](安全轴):`/health` 免鉴权面上 `storeProbe.error` 可披露的**闭集词表**。 * * 为什么必须是闭集而不是「脱敏后的原文」:`/health` 排在 `http/server.ts` 的鉴权门**之前**、缺省全网卡 * 监听 ⇒ 任何能连到这个端口的人都读得到这一格;而它此前装的是**驱动原始异常 message 逐字**,DB 驱动 * 的连接类异常惯于把整条 DSN 回声进去(`mysql://user:pass@host:3306/db`)或带上内网主机名/账号名。 * `trace/redact.ts` 的 `redactSecrets` **挡不住这条**:它的 URL-userinfo 规则只把口令换成 `«redacted»`, * **用户名与 `@` 之后的主机原样留下** —— 而本条要防的正是那两个。闭集词是严格更强的形(值恒为下列 * 字面量之一,构造上不可能携带调用方文本),因此不再叠加脱敏/长度帽:对一个恒为字面量的返回值,那两道 * 都只是装饰。 * * 信息不丢:**完整原文走日志轴** —— 环在 live→dead 翻转拍打的 `store_probe_dead` warn 带 `{ error }` * 原文,运维在自己的日志/采集里读得到全文,那一面本来就是凭证后的。 */ export declare const STORE_PROBE_PUBLIC_PHRASES: readonly ["probe_timeout", "connection_refused", "connection_reset", "host_unreachable", "dns_failure", "network_timeout", "auth_failed", "connection_limit", "probe_failed"]; export type StoreProbePublicPhrase = (typeof STORE_PROBE_PUBLIC_PHRASES)[number]; /** * 原始探针异常 message → 免鉴权面可披露的闭集词。**返回值恒是 {@link STORE_PROBE_PUBLIC_PHRASES} 的 * 一个字面量**(返回类型即闭集,写错一个词是编译错误),永不回声入参。 * * 误分类的代价是「运维读到的分类不精确」,**不是外泄** —— 所以这里的判别用宽松的子串包含即可,不必为 * 精确性把原文碎片带出来。臂序有意义:自家的 race 超时先于泛化的 timeout 臂。 */ export declare function publicStoreProbeError(raw: string): StoreProbePublicPhrase; export declare function createStoreLiveProbe(opts: { probe: () => Promise; intervalMs: number; timeoutMs?: number; logger?: { info?: (msg: string, meta?: Record) => void; warn?: (msg: string, meta?: Record) => void; }; }): StoreLiveProbe; //# sourceMappingURL=store-live-probe.d.ts.map