namespace ZB.MOM.WW.GalaxyRepository;

/// <summary>
///     Connection settings for the AVEVA System Platform Galaxy Repository database.
///     <para>
///     <see cref="SectionName"/> is a generic default; the DI extension accepts an explicit
///     configuration section path so a consumer can bind from its own section (e.g.
///     <c>HistorianGateway:Galaxy</c>).
///     </para>
/// </summary>
public sealed class GalaxyRepositoryOptions
{
    /// <summary>
    ///     Generic default configuration section name. The DI extension accepts an explicit
    ///     section path, so a consumer may bind from a different section (e.g.
    ///     <c>HistorianGateway:Galaxy</c>).
    /// </summary>
    public const string SectionName = "GalaxyRepository";

    /// <summary>
    ///     Default SQL Server connection string for the Galaxy Repository database.
    ///     Single source of truth shared with the integration-test fallback so the
    ///     production default and the live-test default cannot drift.
    /// </summary>
    public const string DefaultConnectionString =
        "Server=localhost;Database=ZB;Integrated Security=True;TrustServerCertificate=True;Encrypt=False;";

    /// <summary>The SQL Server connection string for the Galaxy Repository database.</summary>
    public string ConnectionString { get; init; } = DefaultConnectionString;

    /// <summary>The timeout in seconds for SQL commands executed against the Galaxy Repository.</summary>
    public int CommandTimeoutSeconds { get; init; } = 60;

    /// <summary>
    ///     Interval (seconds) between background refreshes of the dashboard Galaxy summary
    ///     cache. SQL is hit at most once per interval regardless of dashboard render rate.
    /// </summary>
    public int DashboardRefreshIntervalSeconds { get; init; } = 30;

    /// <summary>
    ///     Whether the latest successful Galaxy browse dataset is persisted to disk. When
    ///     enabled, the cache reloads that snapshot at startup so clients can still browse
    ///     last-known data while the Galaxy database is unreachable.
    /// </summary>
    public bool PersistSnapshot { get; init; } = true;

    /// <summary>
    ///     File path for the persisted Galaxy browse snapshot. Ignored when
    ///     <see cref="PersistSnapshot"/> is <see langword="false"/>. There is no built-in
    ///     default path — the consumer supplies a cross-platform-friendly path appropriate to
    ///     its host. When left empty and <see cref="PersistSnapshot"/> is enabled, the
    ///     snapshot store (a later task) decides where to write.
    /// </summary>
    public string SnapshotCachePath { get; init; } = string.Empty;
}
