refactor(kpi): K2/K6/K7 review fixups — empty-batch guard + sealed repo + uniform TryAddEnumerable + KPI-age doc fidelity + coverage

This commit is contained in:
Joseph Doherty
2026-06-17 20:00:43 -04:00
parent 456e61dff3
commit e6c15250ce
7 changed files with 46 additions and 8 deletions
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Kpi;
using ZB.MOM.WW.ScadaBridge.NotificationOutbox.Delivery;
using ZB.MOM.WW.ScadaBridge.NotificationOutbox.Kpi;
@@ -50,7 +51,9 @@ public static class ServiceCollectionExtensions
// KPI history (M6): the recorder singleton enumerates every IKpiSampleSource each
// sampling pass to snapshot the outbox delivery KPIs into the central history store.
services.AddScoped<IKpiSampleSource, NotificationOutboxKpiSampleSource>();
// TryAddEnumerable is idempotent — no double-registration if AddNotificationOutbox
// is ever called more than once, matching the AuditLog (K8) idiom.
services.TryAddEnumerable(ServiceDescriptor.Scoped<IKpiSampleSource, NotificationOutboxKpiSampleSource>());
return services;
}