internal sealed record PlantSettings( int PerUserRequestsPerMinute, int PerUserDailyQuota, int GlobalDailyQuota, bool AllowRemoteHttp) { public static PlantSettings Load(IConfiguration configuration) { var section = configuration.GetSection("PlantFinder"); return new( ReadLimit("PerUserRequestsPerMinute", 10, 600), ReadLimit("PerUserDailyQuota", 4, 10_000), ReadLimit("GlobalDailyQuota", 12, 10_000), section.GetValue("AllowRemoteHttp", false)); int ReadLimit(string key, int fallback, int maximum) { var value = section.GetValue(key, fallback); if (value < 1 || value > maximum) { throw new InvalidOperationException($"Set PlantFinder:{key} from 1 to {maximum}."); } return value; } } }