namespace ZB.MOM.WW.MxGateway.Server.Dashboard;

/// <summary>
/// In-process multicast over <see cref="IDashboardSnapshotService.WatchSnapshotsAsync"/>.
/// One enumeration of the underlying watch is fanned out to every subscriber, so N
/// dashboard circuits cost one snapshot build per tick instead of N — and while nobody
/// subscribes, nothing runs at all.
/// </summary>
/// <remarks>
/// There is no authentication or authorization gate here: the feed is reached only from
/// Blazor dashboard components, whose endpoints already require
/// <see cref="DashboardAuthenticationDefaults.ViewerPolicy"/>, so every caller is a circuit
/// authorized as Viewer. Remote (non-circuit) consumers still go through
/// <c>/hubs/snapshot</c>, which applies the hub authorization policy itself.
/// </remarks>
public interface IDashboardSnapshotFeed
{
    /// <summary>
    /// Watches the shared snapshot stream. Each caller gets the snapshots produced while
    /// it is subscribed; a caller that reads slowly sees only the newest snapshot rather
    /// than a backlog, and never delays the other subscribers.
    /// </summary>
    /// <param name="cancellationToken">Token that ends this caller's subscription.</param>
    /// <returns>An asynchronous stream of dashboard snapshots.</returns>
    IAsyncEnumerable<DashboardSnapshot> WatchAsync(CancellationToken cancellationToken);
}
