namespace ZB.MOM.WW.ScadaBridge.AuditLog.Central;

/// <summary>
/// Enumeration surface consumed by <see cref="SiteAuditReconciliationActor"/> to
/// discover which sites to poll on each reconciliation tick. Extracted so the
/// actor can be unit-tested against a static list without depending on the
/// production <c>ISiteRepository</c> + EF Core DbContext.
/// </summary>
/// <remarks>
/// The production implementation wraps <c>ISiteRepository.GetAllSitesAsync</c>
/// and projects each <c>Site</c> to a <see cref="SiteEntry"/> using the
/// site's configured <c>GrpcNodeAAddress</c> (falling back to
/// <c>GrpcNodeBAddress</c> when NodeA is unset). Sites with NO gRPC address
/// configured are silently skipped — the reconciliation pull cannot reach
/// them, but absence of an address is a configuration decision, not a runtime
/// error.
/// </remarks>
public interface ISiteEnumerator
{
    /// <summary>
    /// Returns the current set of sites the reconciliation puller should visit
    /// on the next tick. Implementations should reflect adds/removes promptly
    /// — the actor calls this once per tick.
    /// </summary>
    /// <param name="ct">Cancellation token for the async enumeration.</param>
    /// <returns>A task that resolves to the current set of site entries to poll on the next reconciliation tick.</returns>
    Task<IReadOnlyList<SiteEntry>> EnumerateAsync(CancellationToken ct = default);
}

/// <summary>
/// One reconciliation target: the site identifier the actor uses as the
/// cursor key and the gRPC endpoint <see cref="IPullAuditEventsClient"/> dials
/// to issue the pull. Endpoint is the bare authority (e.g. <c>http://siteA:8083</c>);
/// transport selection (TLS, keepalive, etc.) is the client's concern.
/// </summary>
public sealed record SiteEntry(string SiteId, string GrpcEndpoint);
