using System.Collections.Generic; using Svrnty.CQRS.Events.Abstractions.EventStore; using System.Threading; using System.Threading.Tasks; using Svrnty.CQRS.Events.Abstractions; namespace Svrnty.CQRS.Events.ConsumerGroups.Abstractions; /// /// High-level API for consuming event streams as part of a consumer group. /// Provides automatic offset management, heartbeating, and error handling. /// public interface IConsumerGroupReader { /// /// Start consuming a stream as part of a consumer group. /// Returns an async enumerable that yields events from the stream. /// The consumer will automatically manage offsets, heartbeats, and polling. /// /// The stream to consume. /// The consumer group ID. /// The consumer ID within the group. /// Consumer group options. /// Cancellation token. /// Async enumerable of events from the stream. /// /// The enumerable will: /// - Start reading from the last committed offset for the group /// - Automatically commit offsets based on the configured strategy /// - Send periodic heartbeats to maintain consumer registration /// - Poll for new events when the stream is caught up /// - Handle consumer registration/unregistration /// IAsyncEnumerable ConsumeAsync( string streamName, string groupId, string consumerId, ConsumerGroupOptions options, CancellationToken cancellationToken = default); /// /// Manually commit an offset for a consumer. /// Useful when using OffsetCommitStrategy.Manual. /// /// The stream name. /// The consumer group ID. /// The consumer ID. /// The offset to commit. /// Cancellation token. /// A task representing the asynchronous operation. Task CommitOffsetAsync( string streamName, string groupId, string consumerId, long offset, CancellationToken cancellationToken = default); /// /// Get the last committed offset for a consumer group. /// /// The stream name. /// The consumer group ID. /// Cancellation token. /// The last committed offset, or null if no offset has been committed. Task GetLastCommittedOffsetAsync( string streamName, string groupId, CancellationToken cancellationToken = default); }