60 lines
2.1 KiB
C#
60 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Svrnty.CQRS.Events.Abstractions.Configuration;
|
|
|
|
/// <summary>
|
|
/// Configuration for stream performance tuning.
|
|
/// </summary>
|
|
public class PerformanceConfiguration
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets the batch size for bulk operations.
|
|
/// </summary>
|
|
public int? BatchSize { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether to enable compression for stored events.
|
|
/// </summary>
|
|
public bool? EnableCompression { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the compression algorithm to use (e.g., "gzip", "zstd").
|
|
/// </summary>
|
|
public string? CompressionAlgorithm { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether to enable indexing on metadata fields.
|
|
/// </summary>
|
|
public bool? EnableIndexing { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the list of metadata fields to index.
|
|
/// </summary>
|
|
public List<string>? IndexedFields { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the cache size for frequently accessed events.
|
|
/// </summary>
|
|
public int? CacheSize { get; set; }
|
|
|
|
/// <summary>
|
|
/// Validates the performance configuration.
|
|
/// </summary>
|
|
/// <exception cref="ArgumentException">Thrown when configuration is invalid.</exception>
|
|
public void Validate()
|
|
{
|
|
if (BatchSize.HasValue && BatchSize.Value <= 0)
|
|
throw new ArgumentException("BatchSize must be positive", nameof(BatchSize));
|
|
|
|
if (EnableCompression == true && string.IsNullOrWhiteSpace(CompressionAlgorithm))
|
|
throw new ArgumentException("CompressionAlgorithm must be specified when EnableCompression is true", nameof(CompressionAlgorithm));
|
|
|
|
if (EnableIndexing == true && (IndexedFields == null || IndexedFields.Count == 0))
|
|
throw new ArgumentException("IndexedFields must be specified when EnableIndexing is true", nameof(IndexedFields));
|
|
|
|
if (CacheSize.HasValue && CacheSize.Value < 0)
|
|
throw new ArgumentException("CacheSize cannot be negative", nameof(CacheSize));
|
|
}
|
|
}
|