feat(localdb): periodic oplog maintenance service (caps enforcement + tombstone pruning, both roles)
Claude-Session: https://claude.ai/code/session_01BL2Vu1ESDQ9SCN4gVKkdts
This commit is contained in:
+8
-1
@@ -16,7 +16,9 @@ public static class ReplicationServiceCollectionExtensions
|
||||
/// configuration section, registers the passive <see cref="LocalDbSyncService"/> as a singleton
|
||||
/// (its single-stream guard must span calls), and registers the initiating
|
||||
/// <see cref="SyncBackgroundService"/> as a hosted service — on a passive node (no
|
||||
/// <see cref="ReplicationOptions.PeerAddress"/>) it starts and immediately idles. Idempotent.
|
||||
/// <see cref="ReplicationOptions.PeerAddress"/>) it starts and immediately idles. The periodic
|
||||
/// <see cref="MaintenanceBackgroundService"/> (oplog caps enforcement + tombstone pruning) is
|
||||
/// also always registered and runs on BOTH roles — passive nodes need it too. Idempotent.
|
||||
/// Requires <see cref="LocalDbServiceCollectionExtensions.AddZbLocalDb"/> to have been called
|
||||
/// for the <see cref="ILocalDb"/> the adapters depend on.
|
||||
/// </summary>
|
||||
@@ -59,6 +61,11 @@ public static class ReplicationServiceCollectionExtensions
|
||||
|
||||
services.AddSingleton<LocalDbSyncService>();
|
||||
services.AddHostedService<SyncBackgroundService>();
|
||||
// Factory registration because the ctor takes the internal shared OplogStore singleton.
|
||||
services.AddHostedService(sp => new MaintenanceBackgroundService(
|
||||
sp.GetRequiredService<OplogStore>(),
|
||||
sp.GetRequiredService<IOptions<ReplicationOptions>>(),
|
||||
sp.GetRequiredService<Microsoft.Extensions.Logging.ILoggerFactory>()));
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user