fix(siteeventlog): gate EventLogPurge to active node via IClusterNodeProvider.SelfIsPrimary (#29, M2.15)
This commit is contained in:
@@ -96,6 +96,19 @@ public static class SiteServiceRegistration
|
|||||||
return new AkkaClusterNodeProvider(akkaService, siteRole);
|
return new AkkaClusterNodeProvider(akkaService, siteRole);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// SiteEventLogging-019 / #29 (M2.15): the EventLogPurgeService runs on every
|
||||||
|
// site host node but consults this optional gate each tick and early-exits on
|
||||||
|
// the standby. Register it to delegate to IClusterNodeProvider.SelfIsPrimary
|
||||||
|
// (the canonical "this node is Up AND cluster leader" check) so purge runs ONLY
|
||||||
|
// on the active node — no duplicated cluster logic. Non-clustered test hosts that
|
||||||
|
// never call SiteServiceRegistration leave it unregistered, so the purge defaults
|
||||||
|
// to always-run (the pre-fix behaviour, preserved).
|
||||||
|
services.AddSingleton<SiteEventLogActiveNodeCheck>(sp =>
|
||||||
|
{
|
||||||
|
var nodeProvider = sp.GetRequiredService<IClusterNodeProvider>();
|
||||||
|
return () => nodeProvider.SelfIsPrimary;
|
||||||
|
});
|
||||||
|
|
||||||
// Options binding
|
// Options binding
|
||||||
BindSharedOptions(services, config);
|
BindSharedOptions(services, config);
|
||||||
services.Configure<SiteRuntimeOptions>(config.GetSection("ScadaBridge:SiteRuntime"));
|
services.Configure<SiteRuntimeOptions>(config.GetSection("ScadaBridge:SiteRuntime"));
|
||||||
|
|||||||
@@ -405,6 +405,9 @@ public class SiteCompositionRootTests : IDisposable
|
|||||||
new object[] { typeof(IEventLogQueryService) },
|
new object[] { typeof(IEventLogQueryService) },
|
||||||
new object[] { typeof(ISiteIdentityProvider) },
|
new object[] { typeof(ISiteIdentityProvider) },
|
||||||
new object[] { typeof(IHealthReportTransport) },
|
new object[] { typeof(IHealthReportTransport) },
|
||||||
|
// M2.15 (#29): the active-node purge gate must be registered on site nodes
|
||||||
|
// so EventLogPurge only runs on the active node.
|
||||||
|
new object[] { typeof(SiteEventLogActiveNodeCheck) },
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Scoped services ---
|
// --- Scoped services ---
|
||||||
|
|||||||
Reference in New Issue
Block a user