fix(health): decouple AuditCentralHealthSnapshot from ActorSystem (#23 M6)
The snapshot's per-site stalled latch now lives on the snapshot itself and is fed by SiteAuditTelemetryStalledTracker via ApplyStalled, removing the chain that required ActorSystem at DI composition time. The tracker is now constructed by AkkaHostedService once ActorSystem.Create returns, with a lock-guarded auxiliary-disposable list so concurrent host start/stop in tests cannot race the enumeration.
This commit is contained in:
@@ -24,8 +24,7 @@ public class CentralAuditRedactionFailureCounterTests : TestKit
|
||||
[Fact]
|
||||
public void Increment_Routes_To_Snapshot()
|
||||
{
|
||||
using var tracker = new SiteAuditTelemetryStalledTracker(Sys);
|
||||
var snapshot = new AuditCentralHealthSnapshot(tracker);
|
||||
var snapshot = new AuditCentralHealthSnapshot();
|
||||
var counter = new CentralAuditRedactionFailureCounter(snapshot);
|
||||
|
||||
counter.Increment();
|
||||
@@ -60,10 +59,10 @@ public class CentralAuditRedactionFailureCounterTests : TestKit
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton<ILoggerFactory, NullLoggerFactory>();
|
||||
services.AddSingleton(typeof(ILogger<>), typeof(NullLogger<>));
|
||||
// The AuditCentralHealthSnapshot ctor takes the stalled tracker
|
||||
// which itself needs an ActorSystem — register a real system
|
||||
// (test-kit's Sys) so the DI graph composes.
|
||||
services.AddSingleton<ActorSystem>(Sys);
|
||||
// AuditCentralHealthSnapshot no longer takes a tracker dependency —
|
||||
// the tracker is constructed later by the Akka bootstrap because its
|
||||
// ctor needs an ActorSystem (not a DI-resolvable singleton). The
|
||||
// snapshot itself composes purely from primitives.
|
||||
services.AddAuditLog(config);
|
||||
services.AddAuditLogCentralMaintenance(config);
|
||||
using var provider = services.BuildServiceProvider();
|
||||
|
||||
Reference in New Issue
Block a user