feat(phase-4): application layer + background workers — 202/202 tests green
Use cases (Marathon.Application/UseCases/): - PullUpcomingEventsUseCase: scrape + persist new events + capture pre-match snapshots - PullLiveOddsUseCase: refresh live snapshots for all stored events - PullResultsUseCase: Phase 4 scaffold; delegates to ScrapeResultsAsync (Phase 3 no-op); Phase 8 will replace with watch-list polling - ExportToExcelUseCase: resolves export dir from StorageOptions, delegates to IExcelExporter ApplicationModule.AddMarathonApplication(IServiceCollection) — no IConfiguration needed. Background workers (Marathon.Infrastructure/Workers/): - UpcomingEventsPoller: Cronos 6-field cron schedule (default every 6 h) - LiveOddsPoller: fixed interval (WorkerOptions.LivePollIntervalSeconds, default 30 s) - ResultsWatchListPoller: scaffold, disabled by default (WorkerOptions.ResultsPollerEnabled=false) All three: exception-swallowing, cancellation-aware, scoped DI via CreateAsyncScope(). InfrastructureModule.AddMarathonInfrastructure(IServiceCollection, IConfiguration): - Composes AddMarathonPersistence + AddMarathonScraping + WorkerOptions + 3 hosted services App.xaml.cs: replace reflection-based TryAddApplicationAndInfrastructure with direct AddMarathonApplication() + AddMarathonInfrastructure(config) calls. Resolved Phase 3 TODO: bind Sports:Basketball:QuarterMode from config in ScrapingModule. appsettings.json: add Workers.LivePollIntervalSeconds, ResultsPollIntervalSeconds, ResultsPollerEnabled; add Sports.Basketball.QuarterMode. Settings.razor + WorkerOptions (UI) + SharedResource.*.resx: surface new Workers fields. Tests: +14 Application use-case tests, +3 Infrastructure worker tests (185 → 202 total).
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using Marathon.Application.UseCases;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Marathon.Application;
|
||||
|
||||
/// <summary>
|
||||
/// DI registration helpers for the Marathon.Application layer.
|
||||
/// Call <see cref="AddMarathonApplication"/> from the composition root (host or
|
||||
/// <c>InfrastructureModule</c>).
|
||||
/// </summary>
|
||||
public static class ApplicationModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers all Application-layer use cases with <c>Scoped</c> lifetime.
|
||||
/// Use cases are scoped so that each background-service cycle or UI request
|
||||
/// gets a fresh unit-of-work from its own DI scope.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// No <see cref="Microsoft.Extensions.Configuration.IConfiguration"/> is
|
||||
/// required here — the Application layer has no direct configuration bindings.
|
||||
/// Infrastructure and UI layers bind their own options against the shared
|
||||
/// JSON sections.
|
||||
/// </remarks>
|
||||
public static IServiceCollection AddMarathonApplication(this IServiceCollection services)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
|
||||
services.AddScoped<PullUpcomingEventsUseCase>();
|
||||
services.AddScoped<PullLiveOddsUseCase>();
|
||||
services.AddScoped<PullResultsUseCase>();
|
||||
services.AddScoped<ExportToExcelUseCase>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user