54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
using System;
|
|
|
|
namespace Svrnty.CQRS.Events.Abstractions.Configuration;
|
|
|
|
/// <summary>
|
|
/// Configuration for stream retention policies.
|
|
/// </summary>
|
|
public class RetentionConfiguration
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets the maximum age of events before cleanup.
|
|
/// </summary>
|
|
public TimeSpan? MaxAge { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the maximum total size in bytes before cleanup.
|
|
/// </summary>
|
|
public long? MaxSizeBytes { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the maximum number of events before cleanup.
|
|
/// </summary>
|
|
public long? MaxEventCount { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether to enable table partitioning for this stream.
|
|
/// </summary>
|
|
public bool? EnablePartitioning { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the partition interval (e.g., daily, weekly, monthly).
|
|
/// </summary>
|
|
public TimeSpan? PartitionInterval { get; set; }
|
|
|
|
/// <summary>
|
|
/// Validates the retention configuration.
|
|
/// </summary>
|
|
/// <exception cref="ArgumentException">Thrown when configuration is invalid.</exception>
|
|
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));
|
|
}
|
|
}
|