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

namespace ZB.MOM.WW.OtOpcUa.Core.VirtualTags;

/// <summary>
///     Sink for virtual-tag evaluation results that the operator marked
///     <c>Historize = true</c>. Stream G wires this to the existing history-write path
///     drivers use; tests inject a fake recorder.
/// </summary>
/// <remarks>
///     Emission is fire-and-forget from the evaluation pipeline — a slow historian must
///     not block script evaluations. Implementations queue internally and drain on their
///     own cadence.
/// </remarks>
public interface IHistoryWriter
{
    /// <summary>Records a data value snapshot for the given path.</summary>
    /// <param name="path">The virtual tag path.</param>
    /// <param name="value">The data value snapshot to record.</param>
    void Record(string path, DataValueSnapshot value);
}

/// <summary>No-op default used when no historian is configured.</summary>
public sealed class NullHistoryWriter : IHistoryWriter
{
    public static readonly NullHistoryWriter Instance = new();

    /// <inheritdoc />
    public void Record(string path, DataValueSnapshot value) { }
}
