2.3 Startup vs reload asymmetry (FramesRegistry)
FramesRegistry validates strictly on construction (fail-fast at startup) and leniently on hot-reload (skip invalid frames with a warning, keep valid ones serving). Exposes TryGetByName/TryGetByMac over the current valid set. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
d0fa755534
commit
0dc0da8de1
5 files changed
+462
-5
No files matched your search
@@ -1,5 +1,4 @@
|
||||
using FrameProcessor.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -27,13 +26,20 @@ builder.Services.AddOptions<ApiKeyOptions>()
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
|
||||
builder.Services.AddSingleton<IValidateOptions<FramesOptions>, FramesOptionsValidator>();
|
||||
// FramesOptions is bound but not validated via the options pipeline so that
|
||||
// IOptionsMonitor<FramesOptions> can fire OnChange with invalid content during
|
||||
// hot-reload without throwing. FramesRegistry takes responsibility for both
|
||||
// strict startup validation (in its constructor) and lenient reload validation.
|
||||
builder.Services.AddOptions<FramesOptions>()
|
||||
.Bind(builder.Configuration)
|
||||
.ValidateOnStart();
|
||||
.Bind(builder.Configuration);
|
||||
builder.Services.AddSingleton<FramesOptionsValidator>();
|
||||
builder.Services.AddSingleton<FramesRegistry>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Eagerly resolve FramesRegistry so an invalid frames.json fails startup fast.
|
||||
_ = app.Services.GetRequiredService<FramesRegistry>();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
Reference in new issue
Block a user