HTTP polling provider for Cocoar.Configuration enabling remote configuration sources with configurable polling intervals, automatic retries, and failure sentinel values for resilient distributed configuration management.
IReactiveConfig<T> (no opt-in).IReactiveConfig<(T1,T2,...,TN)> for atomic aligned multi-config state (any tuple arity) with strict validation.docs/health-monitoring.md).IOptions<T> ceremony).Fetch → Select → Mount → Merge.__ / : hierarchy mapping.IConfiguration (extension package).IConfigurationHealthService.IReactiveConfig<T> & tuple variants auto available..DisableAutoRegistration() (concrete) or global setup.ExposedType<IMy>().DisableAutoRegistration().dotnet add package Cocoar.Configuration
# For ASP.NET Core integration:
dotnet add package Cocoar.Configuration.AspNetCorevar builder = WebApplication.CreateBuilder(args);
builder.Services.AddCocoarConfiguration(rule => [
rule.For<AppSettings>().FromFile("appsettings.json").Select("App"),
rule.For<AppSettings>().FromEnvironment("APP_")
], setup => [
setup.ConcreteType<AppSettings>()
.ExposeAs<IAppSettings>() // optional interface exposure
]);
var app = builder.Build();
// Interface injection (Scoped)
app.MapGet("/feature", (IAppSettings cfg) => new { cfg.FeatureFlag, cfg.Message });
// Reactive tuple injection
app.MapGet("/composite", (IReactiveConfig<(AppSettings App, LoggingConfig Log)> composite) =>
{
var (appCfg, log) = composite.CurrentValue;
return new { appCfg.Version, log.Level };
});
app.Run();// Inside your configure function:
builder.AddCocoarConfiguration(rule => [
rule.For<AppSettings>().FromFile("appsettings.json")
], setup => [
// Skip concrete registration
setup.ConcreteType<AppSettings>().DisableAutoRegistration(),
// Globally suppress interface registration (affects any future exposure of IAppSettings)
setup.ExposedType<IAppSettings>().DisableAutoRegistration()
]);The When() method now supports config-aware predicates using IConfigurationAccessor:
builder.Services.AddCocoarConfiguration(rule => [
// Load tenant info first
rule.For<TenantSettings>().FromFile("tenant.json"),
// Conditionally load premium features based on tenant tier
rule.For<PremiumFeatures>().FromFile("premium-features.json")
.When(accessor =>
{
var tenant = accessor.GetRequiredConfig<TenantSettings>();
return tenant.Tier == "Premium";
}),
// Conditionally load based on environment variable
rule.For<DebugSettings>().FromFile("debug-settings.json")
.When(_ => Environment.GetEnvironmentVariable("DEBUG_MODE") == "true")
]);The predicate is evaluated during initialization and on every recompute—if it returns false, the rule is skipped entirely. This works seamlessly with dynamic rules for powerful conditional logic.
| Project | Description |
|---|---|
| BasicUsage | ASP.NET Core + file + environment overlay |
| FileLayering | Multi-file layering (base/env/local) |
| DynamicDependencies | Rules derived from earlier snapshots |
| ConditionalRulesExample | Config-aware conditional rule execution with When() |
| AspNetCoreExample | Minimal API endpoints exposing config |
| GenericProviderAPI | Using generic provider registration APIs |
| HttpPollingExample | Remote HTTP polling pattern |
| MicrosoftAdapterExample | Integrate existing IConfigurationSource providers |
| StaticProviderExample | Static seeding with JSON / factories |
| SimplifiedCoreExample | Pure core (no DI) usage |
| BindingExample | Interface exposure without DI container |
| TupleReactiveExample | Tuple-based aligned reactive snapshots |
More: Examples README.
Extensive automated test suite (>200 tests) spanning:
See the Testing Guide for details.
LICENSE, NOTICE)This project is licensed under the Apache License, Version 2.0. See NOTICE for attribution.
“Cocoar” and related marks are trademarks of COCOAR e.U. Usage in forks should preserve attribution and avoid implying endorsement. See TRADEMARKS.