using System.Threading.Channels;
using ZB.MOM.WW.LocalDb.Contracts;

namespace ZB.MOM.WW.LocalDb.Replication.Internal;

/// <summary>
/// The transport seam a <see cref="SyncSession"/> runs over: an outbound send delegate plus an
/// inbound message reader. Task 11 adapts a gRPC duplex stream to this; tests wire two in-memory
/// <see cref="Channel{T}"/> pairs crosswise. The session's single writer task is the only caller
/// of <see cref="Send"/>, so an adapter's stream writer never sees concurrent sends. Send MUST
/// honor its CancellationToken even when blocked on transport flow control (teardown relies on it).
/// </summary>
internal sealed class SyncDuplex
{
    public required Func<SyncMessage, CancellationToken, Task> Send { get; init; }

    public required ChannelReader<SyncMessage> Inbox { get; init; }
}
