using System; namespace Svrnty.CQRS.Events.PostgreSQL.Retention; /// /// Configuration options for the retention policy background service. /// public class RetentionServiceOptions { /// /// How often to check and enforce retention policies. /// Default: 1 hour /// public TimeSpan CleanupInterval { get; set; } = TimeSpan.FromHours(1); /// /// Start of cleanup window (UTC time of day). /// Cleanup only runs during this window to avoid peak hours. /// Default: 2 AM UTC /// public TimeSpan CleanupWindowStart { get; set; } = TimeSpan.FromHours(2); /// /// End of cleanup window (UTC time of day). /// Default: 6 AM UTC /// public TimeSpan CleanupWindowEnd { get; set; } = TimeSpan.FromHours(6); /// /// Whether the retention service is enabled. /// If false, retention policies will not be enforced automatically. /// Default: true /// public bool Enabled { get; set; } = true; /// /// Whether to use the cleanup window restriction. /// If false, cleanup runs whenever the interval elapses, regardless of time. /// Default: true /// public bool UseCleanupWindow { get; set; } = true; /// /// Validates the configuration. /// public void Validate() { if (CleanupInterval <= TimeSpan.Zero) throw new ArgumentException("CleanupInterval must be positive", nameof(CleanupInterval)); if (CleanupWindowStart < TimeSpan.Zero || CleanupWindowStart >= TimeSpan.FromHours(24)) throw new ArgumentException("CleanupWindowStart must be between 00:00:00 and 23:59:59", nameof(CleanupWindowStart)); if (CleanupWindowEnd < TimeSpan.Zero || CleanupWindowEnd >= TimeSpan.FromHours(24)) throw new ArgumentException("CleanupWindowEnd must be between 00:00:00 and 23:59:59", nameof(CleanupWindowEnd)); } }