using System; using Svrnty.CQRS.Events.Abstractions.Schema; using System.Collections.Generic; namespace Svrnty.CQRS.Events.Abstractions.Subscriptions; /// /// Represents a subscription configuration for consuming events from a stream. /// /// /// /// A subscription defines HOW and WHAT events should be consumed: /// - Which stream to listen to /// - Which subscription mode (Broadcast, Exclusive, ConsumerGroup, ReadReceipt) /// - Optional event type filters /// - Delivery options /// /// /// Subscription vs Consumer: /// - Subscription = Configuration (WHAT to listen to) /// - Consumer = Active listener (WHO is listening) /// - Multiple consumers can subscribe to the same subscription /// /// public interface ISubscription { /// /// Unique identifier for this subscription. /// string SubscriptionId { get; } /// /// Name of the stream to subscribe to. /// string StreamName { get; } /// /// Subscription mode determining how events are distributed to consumers. /// SubscriptionMode Mode { get; } /// /// Optional filter for specific event types. /// If null or empty, all event types are included. /// HashSet? EventTypeFilter { get; } /// /// Whether this subscription is currently active. /// Inactive subscriptions do not deliver events. /// bool IsActive { get; } /// /// When this subscription was created. /// DateTimeOffset CreatedAt { get; } /// /// Optional description of this subscription's purpose. /// string? Description { get; } /// /// Maximum number of concurrent consumers allowed for this subscription. /// Only applies to ConsumerGroup mode. Null means unlimited. /// int? MaxConcurrentConsumers { get; } /// /// Visibility timeout for in-flight events (how long before auto-requeue). /// Only applies to Exclusive and ConsumerGroup modes. /// TimeSpan VisibilityTimeout { get; } /// /// Optional metadata for this subscription (tags, labels, etc.). /// IReadOnlyDictionary? Metadata { get; } // ======================================================================== // Phase 5: Schema Evolution Support // ======================================================================== /// /// Whether to automatically upcast events to newer versions. /// /// /// /// When enabled, events are automatically upcast to the latest version /// (or specified ) before being delivered /// to consumers. /// /// /// Requires to be registered in DI. /// /// bool EnableUpcasting { get; } /// /// Target event version for upcasting (null = latest version). /// /// /// /// If null, events are upcast to the latest registered version. /// If specified, events are upcast to this specific version. /// /// /// Only used when is true. /// /// int? TargetEventVersion { get; } }