using System; using Svrnty.CQRS.Events.Abstractions.Streaming; using Svrnty.CQRS.Events.Abstractions.Subscriptions; namespace Svrnty.CQRS.Events.Abstractions.Configuration; /// /// Default implementation of remote stream configuration. /// public sealed class RemoteStreamConfiguration : IRemoteStreamConfiguration { /// /// Initializes a new instance of the class. /// /// The name of the remote stream. public RemoteStreamConfiguration(string streamName) { if (string.IsNullOrWhiteSpace(streamName)) throw new ArgumentException("Stream name cannot be null or whitespace.", nameof(streamName)); StreamName = streamName; } /// public string StreamName { get; } /// public string ProviderType { get; set; } = "RabbitMQ"; /// public string ConnectionString { get; set; } = string.Empty; /// public SubscriptionMode Mode { get; set; } = SubscriptionMode.ConsumerGroup; /// public bool AutoDeclareTopology { get; set; } = true; /// public int PrefetchCount { get; set; } = 10; /// public AcknowledgmentMode AcknowledgmentMode { get; set; } = AcknowledgmentMode.Auto; /// public int MaxRedeliveryAttempts { get; set; } = 3; /// public void Validate() { if (string.IsNullOrWhiteSpace(StreamName)) throw new InvalidOperationException("StreamName cannot be null or whitespace."); if (string.IsNullOrWhiteSpace(ProviderType)) throw new InvalidOperationException("ProviderType must be specified."); if (string.IsNullOrWhiteSpace(ConnectionString)) throw new InvalidOperationException("ConnectionString must be specified."); if (PrefetchCount <= 0) throw new InvalidOperationException("PrefetchCount must be positive."); if (MaxRedeliveryAttempts < 0) throw new InvalidOperationException("MaxRedeliveryAttempts cannot be negative."); } }