using System;
namespace Svrnty.CQRS.Events.ConsumerGroups.Monitoring;
///
/// Configuration options for the consumer health monitor background service.
///
public class ConsumerHealthMonitorOptions
{
///
/// How often to check for stale consumers.
/// Default: 30 seconds
///
public TimeSpan CleanupInterval { get; set; } = TimeSpan.FromSeconds(30);
///
/// How long a consumer can be inactive before being considered stale.
/// This should be longer than the heartbeat interval to avoid false positives.
/// Default: 60 seconds
///
public TimeSpan SessionTimeout { get; set; } = TimeSpan.FromSeconds(60);
///
/// Whether the health monitor is enabled.
/// Default: true
///
public bool Enabled { get; set; } = true;
///
/// Validates the configuration.
///
public void Validate()
{
if (CleanupInterval <= TimeSpan.Zero)
throw new ArgumentException("CleanupInterval must be positive", nameof(CleanupInterval));
if (SessionTimeout <= TimeSpan.Zero)
throw new ArgumentException("SessionTimeout must be positive", nameof(SessionTimeout));
if (SessionTimeout < TimeSpan.FromSeconds(10))
throw new ArgumentException("SessionTimeout should be at least 10 seconds to avoid false positives", nameof(SessionTimeout));
}
}