using System.Threading.Channels;
using Nexus.Api.Models;

namespace Nexus.Api.Services;

public interface ILiveUpdateService
{
    Task<LiveUpdateSubscription> SubscribeAsync(long? afterSequence = null, CancellationToken ct = default);
    LiveUpdateEnvelope Publish(string type, object payload, string channel = "dashboard");
    long CurrentSequence { get; }
}

public sealed class LiveUpdateSubscription
{
    public ChannelReader<LiveUpdateEnvelope> Reader { get; init; } = default!;
    public long StartingSequence { get; init; }
}
