Resolve all 46 low-severity architecture review findings

This commit is contained in:
Joseph Doherty
2026-09-09 22:56:36 -04:00
parent fef3e7675f
commit 9ee402bbcd
139 changed files with 2621 additions and 1082 deletions
@@ -0,0 +1,33 @@
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Kpi;
namespace ZB.MOM.WW.ScadaBridge.KpiHistory;
/// <summary>
/// Root-provider-owned admission for source collections. Actor replacement must not
/// start another call while an earlier cancellation-ignoring collection still owns its scope.
/// Registration indices are stable because the root provider's service collection is immutable.
/// </summary>
internal sealed class KpiSourceAdmission
{
private readonly object _gate = new();
private readonly Dictionary<int, Task<IReadOnlyList<KpiSample>>> _tasks = new();
internal bool TryStart(
int registrationIndex,
Func<Task<IReadOnlyList<KpiSample>>> collect,
out Task<IReadOnlyList<KpiSample>> collection)
{
lock (_gate)
{
if (_tasks.TryGetValue(registrationIndex, out var existing) && !existing.IsCompleted)
{
collection = existing;
return false;
}
collection = Task.Run(collect);
_tasks[registrationIndex] = collection;
return true;
}
}
}