using ZB.MOM.WW.OtOpcUa.Core.Abstractions;

namespace ZB.MOM.WW.OtOpcUa.Driver.MTConnect;

/// <summary>
///     Driver-internal identity of one <c>/sample</c> subscription, matching the sibling drivers'
///     shape (Galaxy's <c>GalaxySubscriptionHandle</c>, the shared <c>PollGroupEngine</c>'s
///     <c>PollSubscriptionHandle</c>): a monotonic per-driver id plus a diagnostic string that
///     carries it into logs.
/// </summary>
/// <remarks>
///     <para>
///         <b>Every handle shares ONE Agent stream.</b> Unlike a polled driver, where each
///         subscription owns a loop, MTConnect's <c>/sample</c> long poll is per-Agent: the driver
///         opens exactly one and fans each chunk out to whichever handles subscribe the reporting
///         DataItem. The handle is therefore purely an identity — it owns no connection, no task,
///         and no cursor — and dropping one only stops the stream when it was the last.
///     </para>
///     <para>
///         A <see langword="record"/> for value equality on the id, so a handle that has round-tripped
///         through the caller still resolves. The id is never reused within a driver instance.
///     </para>
/// </remarks>
/// <param name="SubscriptionId">The monotonic per-driver subscription id.</param>
internal sealed record MTConnectSampleHandle(long SubscriptionId) : ISubscriptionHandle
{
    /// <inheritdoc/>
    public string DiagnosticId => $"mtconnect-sub-{SubscriptionId}";
}
