perf(adminui): 5s snapshot cache in front of the script tag catalog

This commit is contained in:
Joseph Doherty
2026-08-16 04:05:07 -04:00
parent ba977dbe0d
commit 3795899d10
4 changed files with 259 additions and 8 deletions
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using ZB.MOM.WW.OtOpcUa.AdminUI.Hubs;
using ZB.MOM.WW.OtOpcUa.AdminUI.Uns;
@@ -96,6 +97,11 @@ public static class EndpointRouteBuilderExtensions
// Roslyn-backed Monaco script-editor analysis (diagnostics/completions/hover/...).
services.AddScoped<ScriptAnalysis.ScriptAnalysisService>();
services.AddScoped<ScriptAnalysis.IScriptTagCatalog, ScriptAnalysis.ScriptTagCatalog>();
// The catalog stays Scoped (per circuit); its six-table fleet-wide projection is shared across
// circuits behind a 5 s TTL snapshot — Monaco fires a completion request per keystroke.
services.AddSingleton<ScriptAnalysis.ScriptTagCatalogSnapshotCache>();
// TryAdd so a host that already bound a clock (test harness, future fused-host registration) wins.
services.TryAddSingleton<TimeProvider>(TimeProvider.System);
// Certificate-store actions (trust/untrust/delete) for the /certificates page.
services.AddSingleton<Certificates.CertificateStoreManager>();