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> in DI automaticallyIReactiveConfig<(T1,T2,...,TN)> for aligned, change-filtered multi-config snapshots (any arity) with strict element validationIOptions<T> or attributes.Fetch → Select → Mount → Merge pipeline..Required(true/false))..When(() => condition)).__ and : delimiters build JSON hierarchy.IConfiguration.IConfigurationHealthService for all providers.IReactiveConfig<T> registered automatically in DI.IReactiveConfig<(A,B,C)> (any tuple size) for atomic multi-config snapshots (only configured types or bound interfaces allowed).Bind.Type<T>().To<IMyConfig>()) for clean contracts.dotnet add package Cocoar.Configuration
# For ASP.NET Core integration:
dotnet add package Cocoar.Configuration.AspNetCorevar builder = WebApplication.CreateBuilder(args);
// Register layered configuration (file + environment overlay)
builder.Services.AddCocoarConfiguration([
Rule.From.File("appsettings.json").Select("App").For<AppSettings>(),
Rule.From.Environment("APP_").For<AppSettings>()
]);
var app = builder.Build();
// Simple endpoint: inject concrete snapshot (Scoped)
app.MapGet("/feature", (AppSettings cfg) => new {
snapshotFlag = cfg.FeatureFlag, // Value at scope start (request)
message = cfg.Message
});
// Tuple reactive usage example (arbitrary arity)
app.MapGet("/composite", (IReactiveConfig<(AppSettings App, FeatureFlags Flags, LoggingConfig Log)> composite) =>
{
var (appCfg, flags, log) = composite.CurrentValue;
return new {
feature = flags.Enabled.Contains("NewX"),
level = log.Level,
appCfg.Version
};
});
// Guard: invalid tuple (e.g. unbound interface) throws immediately
// var bad = manager.GetReactiveConfig<(UnconfiguredType, IUnboundInterface)>(); // -> InvalidOperationExceptionEach example is a standalone runnable project under src/Examples/:
| Project | Description |
|---|---|
| BasicUsage | Common ASP.NET Core pattern (file + env overlay) |
| FileLayering | Multiple JSON layering (base + env + local) |
| DynamicDependencies | Later rules derive values from earlier configs |
| AspNetCoreExample | Minimal API exposing config via endpoints |
| GenericProviderAPI | Generic provider registration API usage |
| HttpPollingExample | Remote HTTP polling configuration pattern |
| MicrosoftAdapterExample | Integrating existing IConfigurationSource assets |
| ServiceLifetimes | DI lifetime & keyed registration control |
| StaticProviderExample | Static seeding with JSON strings and factory functions |
| DIExample | Comprehensive DI patterns & overrides |
| SimplifiedCoreExample | Pure core (no DI) with ConfigManager |
| BindingExample | Interface binding without DI |
| TupleReactiveExample | Tuple-based reactive multi-config snapshot with dynamic updates |
More details: Examples README.
Cocoar.Configuration is backed by an extensive test suite:
See the Testing Guide for patterns and trait filters.
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. Use of the name in forks or derivatives should preserve attribution and avoid implying official endorsement. See TRADEMARKS for permitted and restricted uses.