using System.Threading;
using System.Threading.Tasks;
using ZB.MOM.WW.OtOpcUa.Driver.Historian.Wonderware.Ipc;

namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Wonderware.Backend
{
    /// <summary>
    ///     The actual aahClientManaged-bound writer. Extracted so unit tests can
    ///     substitute a fake without touching the SDK; the production
    ///     implementation lives in <see cref="SdkAlarmHistorianWriteBackend"/>.
    /// </summary>
    /// <remarks>
    ///     Implementations are responsible for connection management + cluster
    ///     failover. The wrapping <see cref="AahClientManagedAlarmEventWriter"/>
    ///     handles batch-level orchestration but delegates the per-event SDK call
    ///     here so the unit tests can drive every documented MxStatus outcome
    ///     without an installed AVEVA Historian.
    /// </remarks>
    public interface IAlarmHistorianWriteBackend
    {
        /// <summary>
        ///     Persist the supplied events to the historian. Returns one outcome per
        ///     input slot in the same order — must always return an array of the same
        ///     length as <paramref name="events"/>.
        /// </summary>
        /// <param name="events">The events to write to the historian.</param>
        /// <param name="cancellationToken">Token to cancel the operation.</param>
        Task<AlarmHistorianWriteOutcome[]> WriteBatchAsync(
            AlarmHistorianEventDto[] events,
            CancellationToken cancellationToken);
    }
}
