using System;
namespace Svrnty.CQRS.Events.Abstractions.Configuration;
///
/// Configuration for stream retention policies.
///
public class RetentionConfiguration
{
///
/// Gets or sets the maximum age of events before cleanup.
///
public TimeSpan? MaxAge { get; set; }
///
/// Gets or sets the maximum total size in bytes before cleanup.
///
public long? MaxSizeBytes { get; set; }
///
/// Gets or sets the maximum number of events before cleanup.
///
public long? MaxEventCount { get; set; }
///
/// Gets or sets whether to enable table partitioning for this stream.
///
public bool? EnablePartitioning { get; set; }
///
/// Gets or sets the partition interval (e.g., daily, weekly, monthly).
///
public TimeSpan? PartitionInterval { get; set; }
///
/// Validates the retention configuration.
///
/// Thrown when configuration is invalid.
public void Validate()
{
if (MaxAge.HasValue && MaxAge.Value <= TimeSpan.Zero)
throw new ArgumentException("MaxAge must be positive", nameof(MaxAge));
if (MaxSizeBytes.HasValue && MaxSizeBytes.Value <= 0)
throw new ArgumentException("MaxSizeBytes must be positive", nameof(MaxSizeBytes));
if (MaxEventCount.HasValue && MaxEventCount.Value <= 0)
throw new ArgumentException("MaxEventCount must be positive", nameof(MaxEventCount));
if (PartitionInterval.HasValue && PartitionInterval.Value <= TimeSpan.Zero)
throw new ArgumentException("PartitionInterval must be positive", nameof(PartitionInterval));
}
}