using System.ComponentModel.DataAnnotations;
namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Wonderware.Client;
///
/// Connection options for WonderwareHistorianClient.
///
///
///
/// Retry / backoff ownership (finding 006): this module performs exactly one
/// in-place transport reconnect inside PipeChannel.InvokeAsync with no delay,
/// and does NOT implement exponential reconnect backoff. Broader retry/backoff is the
/// caller's responsibility — the alarm drain worker
/// (Core.AlarmHistorian.SqliteStoreAndForwardSink) and the read-side
/// history router are expected to layer their own backoff on top.
///
///
/// Named-pipe name the sidecar listens on (matches the sidecar's OTOPCUA_HISTORIAN_PIPE).
/// Per-process shared secret the sidecar will verify in the Hello frame.
/// Diagnostic peer identifier sent in Hello — typically the OtOpcUa instance id.
/// Cap on the named-pipe connect + Hello round trip on each (re)connect.
/// Cap on a single read/write call once connected.
public sealed record WonderwareHistorianClientOptions(
string PipeName,
string SharedSecret,
string PeerName = "OtOpcUa",
TimeSpan? ConnectTimeout = null,
TimeSpan? CallTimeout = null)
{
/// Gets the effective connect timeout, using the default if not explicitly set.
public TimeSpan EffectiveConnectTimeout => ConnectTimeout ?? TimeSpan.FromSeconds(10);
/// Gets the effective call timeout, using the default if not explicitly set.
public TimeSpan EffectiveCallTimeout => CallTimeout ?? TimeSpan.FromSeconds(30);
///
/// Timeout for the AdminUI Test Connect probe, in seconds. The AdminUI clamps to a
/// 60s server-side maximum; this default is what the form pre-fills for new instances.
///
[Display(Name = "Probe timeout (seconds)", Description = "Connection test timeout. Default 15s.", GroupName = "Diagnostics")]
[Range(1, 60)]
public int ProbeTimeoutSeconds { get; init; } = 15;
}