fix(comm): site delete disposes the site's cached gRPC channels via RemoveSiteAsync (plan R2-02 T13)

This commit is contained in:
Joseph Doherty
2026-07-13 10:22:56 -04:00
parent b7f8632db8
commit 4e228110ec
2 changed files with 59 additions and 0 deletions
@@ -1583,6 +1583,18 @@ public class ManagementActor : ReceiveActor
await repo.SaveChangesAsync();
var commService = sp.GetService<CommunicationService>();
commService?.RefreshSiteAddresses();
// Dispose the deleted site's cached gRPC channels — RemoveSiteAsync is the
// factory's designed site-deletion disposal path and previously had no
// production caller (arch review 02 round 2, N8): a deleted site's channels
// (both node endpoints) otherwise persist until process restart. Null-safe:
// test/composition roots without the factory skip it. Any live-alarm
// aggregator for the site reconciles to an empty snapshot and is reaped by
// the viewer linger (documented acceptance — see Component-Communication.md).
var grpcFactory = sp.GetService<ZB.MOM.WW.ScadaBridge.Communication.Grpc.SiteStreamGrpcClientFactory>();
if (grpcFactory is not null && site is not null)
await grpcFactory.RemoveSiteAsync(site.SiteIdentifier);
await AuditAsync(sp, user, "Delete", "Site", cmd.SiteId.ToString(), site?.Name ?? cmd.SiteId.ToString(), null);
return true;
}