44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using System;
|
|
|
|
namespace Svrnty.CQRS.Events.ConsumerGroups.Monitoring;
|
|
|
|
/// <summary>
|
|
/// Configuration options for the consumer health monitor background service.
|
|
/// </summary>
|
|
public class ConsumerHealthMonitorOptions
|
|
{
|
|
/// <summary>
|
|
/// How often to check for stale consumers.
|
|
/// Default: 30 seconds
|
|
/// </summary>
|
|
public TimeSpan CleanupInterval { get; set; } = TimeSpan.FromSeconds(30);
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
public TimeSpan SessionTimeout { get; set; } = TimeSpan.FromSeconds(60);
|
|
|
|
/// <summary>
|
|
/// Whether the health monitor is enabled.
|
|
/// Default: true
|
|
/// </summary>
|
|
public bool Enabled { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// Validates the configuration.
|
|
/// </summary>
|
|
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));
|
|
}
|
|
}
|