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

namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browse;

/// <summary>
///     Driver-side seam between <see cref="DeployWatcher"/> and the gateway. Production
///     wraps <c>GalaxyRepositoryClient.WatchDeployEventsAsync</c>; tests substitute a fake
///     yielding controlled <see cref="DeployEvent"/> instances so the watcher's bootstrap
///     suppression, change detection, reconnect, and shutdown semantics can be exercised
///     without a real gRPC stream.
/// </summary>
public interface IGalaxyDeployWatchSource
{
    /// <summary>
    ///     Subscribe to Galaxy deploy events. The server emits a bootstrap event with the
    ///     current cached state on subscribe, then one event per new
    ///     <c>time_of_last_deploy</c>. Pass <paramref name="lastSeenDeployTime"/> to ask the
    ///     gateway to suppress its bootstrap when the caller already has the current value;
    ///     <see cref="DeployWatcher"/> still suppresses the first event it observes locally
    ///     so a transport reconnect doesn't re-fire on identical state.
    /// </summary>
    /// <param name="lastSeenDeployTime">The last seen deploy time, or null to receive a bootstrap event.</param>
    /// <param name="cancellationToken">The cancellation token.</param>
    /// <returns>An async stream of deploy events, starting with a bootstrap event unless suppressed.</returns>
    IAsyncEnumerable<DeployEvent> WatchAsync(
        DateTimeOffset? lastSeenDeployTime, CancellationToken cancellationToken);
}
