using System;
using Tango.BL.Enumerations;
namespace Tango.Telemetry
{
public class TelemetryPublisherConfiguration
{
///
/// Unique identifier of the machine sending telemetry. Used for tagging and routing.
///
public String SerialNumber { get; set; }
///
/// Enum representing the type of machine (e.g., X1, X4). Helps differentiate models in telemetry.
///
public MachineTypes MachineType { get; set; }
public String Organization { get; set; }
public String Site { get; set; }
///
/// Environment in which the telemetry is being published (e.g., Production, QA, Dev).
///
public String Environment { get; set; }
///
/// Interval for checking and reprocessing failed/pending telemetry from local storage.
///
public TimeSpan PendingStorageCheckInterval { get; set; } = TimeSpan.FromMinutes(1);
///
/// Maximum number of pending telemetry records to process in a single retry cycle.
///
public int MaxPendingStorageTelemetriesPerCycle { get; set; } = 100;
///
/// Frequency at which historical sources are polled to request backlogged or missed telemetry.
///
public TimeSpan HistorySourcesRequestInterval { get; set; } = TimeSpan.FromMinutes(1);
///
/// Maximum number of telemetry packages allowed in memory queues before rejecting new packages.
///
public int MaxPendingTelemetries { get; set; } = 10000;
///
/// Whether exponential backoff should be applied to retry logic per destination.
///
public bool EnableBackoff { get; set; } = false;
///
/// The maximum amount of time to delay retries during exponential backoff.
///
public TimeSpan MaxExponentialBackoff { get; set; } = TimeSpan.FromHours(1);
///
/// Gets or sets the interval at which the published telemetry cache cleanup process should occur.
/// This defines how frequently old published telemetry entries are eligible for pruning,
/// based on their publication timestamp.
///
public TimeSpan PublishedTelemetriesCacheCleanupInterval { get; set; } = TimeSpan.FromHours(1);
public void Validate()
{
if (!SerialNumber.IsNotNullOrEmpty())
throw new ArgumentNullException(nameof(SerialNumber), "SerialNumber is not set or empty.");
if (!Environment.IsNotNullOrEmpty())
throw new ArgumentNullException(nameof(Environment), "Environment is not set or empty.");
if (!Enum.IsDefined(typeof(MachineTypes), MachineType))
throw new ArgumentOutOfRangeException(nameof(MachineType), "MachineType is not a valid enum value.");
if (PendingStorageCheckInterval.TotalSeconds < 5)
throw new ArgumentOutOfRangeException(nameof(PendingStorageCheckInterval), "PendingStorageCheckInterval must be at least 5 seconds.");
}
}
}