using ZB.MOM.WW.MxGateway.Contracts.Proto;

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

/// <summary>
/// Streams MXAccess events to gRPC clients.
/// </summary>
public interface IEventStreamService
{
    /// <summary>
    /// Streams events for the specified session to the caller.
    /// </summary>
    /// <param name="request">Request payload.</param>
    /// <param name="callerKeyId">
    ///     The API key id of the calling client, used to enforce that only the key that opened a
    ///     session may attach or reattach its event stream. <see langword="null"/> when the call
    ///     is unauthenticated (e.g. auth disabled), which only matches a session opened with no
    ///     owner key.
    /// </param>
    /// <param name="cancellationToken">Token to cancel the asynchronous operation.</param>
    /// <returns>The events emitted for the requested session.</returns>
    IAsyncEnumerable<MxEvent> StreamEventsAsync(
        StreamEventsRequest request,
        string? callerKeyId,
        CancellationToken cancellationToken);
}
