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

/// <summary>
///     Sink for driver-health state-change notifications. The runtime DI wires the
///     Akka-DistributedPubSub-backed implementation; tests and dev-stub paths use
///     <see cref="NullDriverHealthPublisher"/> to opt out without changing call sites.
/// </summary>
public interface IDriverHealthPublisher
{
    /// <summary>
    ///     Publishes a health snapshot for one driver instance. Implementations must be
    ///     non-blocking and tolerant of being called from any thread.
    /// </summary>
    void Publish(
        string clusterId,
        string driverInstanceId,
        DriverHealth health,
        int errorCount5Min);
}

/// <summary>
///     Drop-in no-op for tests and dev-stub paths. Production wires the Akka-backed
///     implementation in the Runtime project.
/// </summary>
public sealed class NullDriverHealthPublisher : IDriverHealthPublisher
{
    /// <summary>Singleton instance.</summary>
    public static readonly NullDriverHealthPublisher Instance = new();

    private NullDriverHealthPublisher() { }

    /// <inheritdoc />
    public void Publish(
        string clusterId,
        string driverInstanceId,
        DriverHealth health,
        int errorCount5Min)
    { /* no-op */ }
}
