7.1 IImageUrlFetcher

Add IImageUrlFetcher with HttpClient-backed implementation that enforces
UrlFetch.TimeoutSeconds, MaxRedirects, and MaxBytes. Surfaces failures as
ImageFetchException so the URL-ingestion endpoint can map them to 502.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
zyberzeroandClaude Opus 4.7 committed 2026-06-07 15:51:16 +02:00
1 parent d94009690c
commit 3bef27b286
5 files changed
+140 -1

No files matched your search

+17
View File
@@ -2,6 +2,8 @@ using FrameProcessor.Configuration;
using FrameProcessor.ImagePipeline;
using FrameProcessor.Mqtt;
using FrameProcessor.Storage;
using FrameProcessor.UrlFetch;
using Microsoft.Extensions.Options;
var builder = WebApplication.CreateBuilder(args);
@@ -42,6 +44,21 @@ builder.Services.AddSingleton<ImageStore>();
builder.Services.AddSingleton<MqttPublisher>();
builder.Services.AddHostedService(sp => sp.GetRequiredService<MqttPublisher>());
builder.Services.AddHttpClient<IImageUrlFetcher, ImageUrlFetcher>((sp, client) =>
{
var opts = sp.GetRequiredService<IOptions<UrlFetchOptions>>().Value;
client.Timeout = TimeSpan.FromSeconds(opts.TimeoutSeconds);
})
.ConfigurePrimaryHttpMessageHandler(sp =>
{
var opts = sp.GetRequiredService<IOptions<UrlFetchOptions>>().Value;
return new HttpClientHandler
{
AllowAutoRedirect = true,
MaxAutomaticRedirections = opts.MaxRedirects,
};
});
var app = builder.Build();
// Eagerly resolve FramesRegistry so an invalid frames.json fails startup fast.