Files
ScadaBridge/src/ZB.MOM.WW.ScadaBridge.DeploymentManager/DeploymentStatusNotifier.cs
T
Joseph Doherty eabf270d71 docs: complete XML doc coverage (returns, summaries, inheritdoc)
Resolve all 622 issues flagged by the enhanced CommentChecker: add missing
<returns> tags (incl. the standard phrasing on non-generic Task methods),
add missing <summary> tags, and replace misused/redundant <inheritdoc/> on
members that override or implement nothing with real documentation.
Documentation-only — no behavior change; solution builds clean.
2026-06-03 11:39:32 -04:00

54 lines
2.1 KiB
C#

using Microsoft.Extensions.Logging;
namespace ZB.MOM.WW.ScadaBridge.DeploymentManager;
/// <summary>
/// Default <see cref="IDeploymentStatusNotifier"/> implementation. A simple
/// in-process event broadcaster: registered as a DI singleton so it is shared
/// between the central-process <see cref="DeploymentService"/> and the Central
/// UI's Blazor circuits (CentralUI-006).
///
/// A throwing subscriber must never break the deployment pipeline, so each
/// handler is invoked individually and its exceptions are caught and logged.
/// </summary>
public sealed class DeploymentStatusNotifier : IDeploymentStatusNotifier
{
private readonly ILogger<DeploymentStatusNotifier> _logger;
/// <summary>Initializes a new instance of <see cref="DeploymentStatusNotifier"/>.</summary>
/// <param name="logger">Logger instance used when a subscriber throws.</param>
public DeploymentStatusNotifier(ILogger<DeploymentStatusNotifier> logger)
{
_logger = logger;
}
/// <summary>Raised after each call to <see cref="NotifyStatusChanged"/> to broadcast a deployment status change to all registered subscribers.</summary>
public event Action<DeploymentStatusChange>? StatusChanged;
/// <inheritdoc />
public void NotifyStatusChanged(DeploymentStatusChange change)
{
var handlers = StatusChanged;
if (handlers == null)
return;
// Invoke each subscriber in isolation: one faulting handler (e.g. a
// disposed Blazor circuit) must not stop the others from being notified
// and must not propagate back into the deployment pipeline.
foreach (var handler in handlers.GetInvocationList())
{
try
{
((Action<DeploymentStatusChange>)handler)(change);
}
catch (Exception ex)
{
_logger.LogWarning(ex,
"A deployment-status-change subscriber threw for deployment {DeploymentId} " +
"(status {Status}); continuing with remaining subscribers",
change.DeploymentId, change.Status);
}
}
}
}