mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-14 13:16:16 -08:00
* docs(performance): plan Xtream benchmark * feat(xtream-mock-server): add deterministic 100k fixture * style(xtream-mock-server): apply repository formatting * fix(xtream-mock-server): harden performance fixture data * feat(xtream-mock-server): add performance control plane * docs(performance): correct Xtream capture plan * fix(xtream-mock-server): harden performance controls * fix(xtream-mock-server): harden control lifecycle * feat(performance): add Xtream preload markers * feat(performance): trace Xtream main phases * feat(performance): mark Xtream store publications * feat(performance): trace Xtream database phases * feat(performance): trace Xtream delete cancellation * feat(performance): capture Xtream phase attribution * feat(performance): mark Sources Xtream refresh * test(performance): define Xtream benchmark evidence contracts * test(performance): add Xtream benchmark runner * test(performance): surface failure evidence writes * test(performance): align database read clock * test(performance): preserve capture failure contracts
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
type InvalidateInterception = (abortHeldResponse: boolean) => void;
|
|
|
|
export class PerformanceInterceptionLifecycle {
|
|
private currentGeneration = 1;
|
|
private stopped = false;
|
|
private readonly active = new Map<symbol, InvalidateInterception>();
|
|
|
|
get generation(): number {
|
|
return this.currentGeneration;
|
|
}
|
|
|
|
get shuttingDown(): boolean {
|
|
return this.stopped;
|
|
}
|
|
|
|
isCurrent(generation: number): boolean {
|
|
return generation === this.currentGeneration;
|
|
}
|
|
|
|
register(id: symbol, invalidate: InvalidateInterception): void {
|
|
this.active.set(id, invalidate);
|
|
}
|
|
|
|
unregister(id: symbol): void {
|
|
this.active.delete(id);
|
|
}
|
|
|
|
reset(): void {
|
|
this.invalidate(false);
|
|
}
|
|
|
|
shutdown(): boolean {
|
|
if (this.stopped) return false;
|
|
this.stopped = true;
|
|
this.invalidate(true);
|
|
return true;
|
|
}
|
|
|
|
private invalidate(abortHeldResponses: boolean): void {
|
|
this.currentGeneration += 1;
|
|
for (const invalidate of [...this.active.values()]) {
|
|
invalidate(abortHeldResponses);
|
|
}
|
|
}
|
|
}
|