dotnet-cqrs/Svrnty.CQRS.Events.Abstractions/Configuration/AccessControlConfiguration.cs

54 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
namespace Svrnty.CQRS.Events.Abstractions.Configuration;
/// <summary>
/// Configuration for stream access control and quotas.
/// </summary>
public class AccessControlConfiguration
{
/// <summary>
/// Gets or sets whether anyone can read from this stream.
/// </summary>
public bool PublicRead { get; set; }
/// <summary>
/// Gets or sets whether anyone can write to this stream.
/// </summary>
public bool PublicWrite { get; set; }
/// <summary>
/// Gets or sets the list of users/services allowed to read from this stream.
/// </summary>
public List<string>? AllowedReaders { get; set; }
/// <summary>
/// Gets or sets the list of users/services allowed to write to this stream.
/// </summary>
public List<string>? AllowedWriters { get; set; }
/// <summary>
/// Gets or sets the maximum number of consumer groups allowed for this stream.
/// </summary>
public int? MaxConsumerGroups { get; set; }
/// <summary>
/// Gets or sets the maximum events per second rate limit for this stream.
/// </summary>
public long? MaxEventsPerSecond { get; set; }
/// <summary>
/// Validates the access control configuration.
/// </summary>
/// <exception cref="ArgumentException">Thrown when configuration is invalid.</exception>
public void Validate()
{
if (MaxConsumerGroups.HasValue && MaxConsumerGroups.Value < 0)
throw new ArgumentException("MaxConsumerGroups cannot be negative", nameof(MaxConsumerGroups));
if (MaxEventsPerSecond.HasValue && MaxEventsPerSecond.Value <= 0)
throw new ArgumentException("MaxEventsPerSecond must be positive", nameof(MaxEventsPerSecond));
}
}