实现示例class Circuit { failures = 0 successes = 0 openUntil = 0 record(ok: boolean, now: number) { if (ok) this.successes++; else this.failures++ } rate(): number { const total = this.failures + this.successes; return total ? this.failures / total : 0 } open(now: number, ms: number) { this.openUntil = now + ms } closed(now: number): boolean { return now >= this.openUntil } } function decide(c: Circuit, now: number, threshold: number, backoffMs: number): 'allow' | 'fallback' { if (!c.closed(now)) return 'fallback' if (c.rate() >= threshold) { c.open(now, backoffMs); return 'fallback' } return 'allow' } function pickFallback(candidates: string[], allow: Set<string>): string | null { for (const u of candidates) { try { const x = new URL(u); if (x.protocol === 'https:' && allow.has(x.origin)) return u } catch {} } return null } 审计与运行治理审计失败率与熔断窗口;回退镜像需在白名单内并记录证据。恢复后执行完整性复核与来源确认。

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部
2.051804s