Path: redb-identity/src/redb.Identity.Core/DataProtection/XmlRepositoryRefreshProcessor.cs
Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity
Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Core/DataProtection/XmlRepositoryRefreshProcessor.cs
----
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core;
using redb.Identity.DataProtection;
using redb.Route.Abstractions;
using redb.Identity.Core.Routes;
namespace redb.Identity.Core.DataProtection;
///
/// Reloads the DataProtection XML key-ring snapshot from PROPS storage into
/// . Fired per-tick by a timer:// route
/// (see ). Runs on every replica —
/// this is intentionally NOT cluster-leader-only because each node maintains its own
/// in-process snapshot and must pick up keys rotated by other replicas.
///
internal sealed class XmlRepositoryRefreshProcessor : IProcessor
{
private readonly IServiceProvider _sp;
public XmlRepositoryRefreshProcessor(IServiceProvider sp)
{
ArgumentNullException.ThrowIfNull(sp);
_sp = sp;
}
public async Task Process(IExchange exchange, CancellationToken ct)
{
await using var scope = _sp.CreateAsyncScope();
var repo = scope.ServiceProvider.GetRequiredService();
var redb = scope.ServiceProvider.GetRequiredService();
var logger = scope.ServiceProvider
.GetRequiredService()
.CreateLogger();
var count = await repo.ReloadAsync(redb, ct).ConfigureAwait(false);
logger.LogDebug(
"redb.Identity: DataProtection key-ring snapshot refreshed ({Count} keys)",
count);
}
}