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);
|
||||
});
|
||||
|
||||
// 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
|
||||
BindSharedOptions(services, config);
|
||||
services.Configure<SiteRuntimeOptions>(config.GetSection("ScadaBridge:SiteRuntime"));
|
||||
|
||||
Reference in New Issue
Block a user