using Enmarcha.Backend.Types; using Enmarcha.Backend.Types.Arrivals; namespace Enmarcha.Backend.Services; public class ArrivalsContext { /// /// The full GTFS ID of the stop (e.g., "vitrasa:1400") /// public required string StopId { get; set; } /// /// The public code of the stop (e.g., "1400") /// public required string StopCode { get; set; } /// /// Whether to return a reduced number of arrivals (e.g., 4 instead of 10) /// public bool IsReduced { get; set; } public Position? StopLocation { get; set; } public required List Arrivals { get; set; } public required DateTime NowLocal { get; set; } } public interface IArrivalsProcessor { /// /// Processes the arrivals in the context. Processors are executed in the order they are registered. /// Task ProcessAsync(ArrivalsContext context); } /// /// Orchestrates the enrichment of arrival data through a series of processors. /// This follows a pipeline pattern where each step (processor) adds or modifies data /// in the shared ArrivalsContext. /// public class ArrivalsPipeline { private readonly IEnumerable _processors; public ArrivalsPipeline(IEnumerable processors) { _processors = processors; } /// /// Executes all registered processors sequentially. /// public async Task ExecuteAsync(ArrivalsContext context) { foreach (var processor in _processors) { await processor.ProcessAsync(context); } } }