Konfigo.Client
0.0.4
See the version list below for details.
dotnet add package Konfigo.Client --version 0.0.4
NuGet\Install-Package Konfigo.Client -Version 0.0.4
<PackageReference Include="Konfigo.Client" Version="0.0.4" />
<PackageVersion Include="Konfigo.Client" Version="0.0.4" />
<PackageReference Include="Konfigo.Client" />
paket add Konfigo.Client --version 0.0.4
#r "nuget: Konfigo.Client, 0.0.4"
#:package Konfigo.Client@0.0.4
#addin nuget:?package=Konfigo.Client&version=0.0.4
#tool nuget:?package=Konfigo.Client&version=0.0.4
Konfigo.Client
Client SDK for the Konfigo Realtime Config service. It plugs configuration classes annotated with the attributes from Konfigo.Abstraction into the standard IConfiguration / IOptions<T> pipeline and applies updates at runtime without restarting the host.
How it works
- At host startup
AddRealtimeConfig()onIConfigurationBuilderreads theRealtimeConfigOptionssection and, if the SDK is enabled, registers a gRPC-backed configuration source. The source pulls the initial snapshot and exposes it throughIConfiguration. AddRealtimeConfig()onIServiceCollectionregisters a hosted service that:- Uses reflection to find classes annotated with
[ConfigGroup], describes their schema, and registers a version on the backend (or reuses an existing one if the same version is already known — concurrent startups are guarded by a distributed lock). - Subscribes to the update event stream and applies events to the provider. Each key carries a
Generation; stale events are ignored to avoid races on reconnect. - Binds each group to
IOptions<T>under the key fromConfigGroupAttribute.Key.
- Uses reflection to find classes annotated with
IOptionsMonitor<T> propagates updates correctly — OnChange handlers fire after the provider calls OnReload().
Setup
// Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddRealtimeConfig();
builder.Services.AddRealtimeConfig();
var app = builder.Build();
app.Run();
Minimal appsettings.json:
{
"RealtimeConfigOptions": {
"IsEnabled": true,
"ServiceId": "orders",
"Version": "1.0.0",
"Url": "https://realtime-config.internal",
"PollingInterval": "00:00:05"
}
}
| Field | Description |
|---|---|
IsEnabled |
Master switch. When false, the SDK does not connect. |
ServiceId |
Service identifier in Realtime Config (used for routing). |
Version |
Schema version. Bumped on breaking changes to the set of keys. |
Url |
gRPC endpoint of the Realtime Config service. |
Timestamp |
Starting timestamp for the subscription. Usually left at the default. |
PollingInterval |
Delay between subscription retries after an error. Defaults to 5 seconds. |
Tuning the version registration lock
Version registration is guarded by a distributed lock so that concurrent instances of the same service do not register the same version twice. The lock-acquisition timeout defaults to 30 seconds and can be overridden via the VersionServiceOptions section:
{
"VersionServiceOptions": {
"LockTimeout": "00:01:00"
}
}
Declaring configuration classes
Classes and properties are declared with the attributes from Konfigo.Abstraction:
using Konfigo.Abstraction.Attributes;
[ConfigGroup(key: "Payments", groupName: "Payments", description: "Payment gateway")]
public sealed class PaymentsOptions
{
[ConfigKey(description: "Payment provider", defaultValue: "Stripe")]
public string Provider { get; set; } = string.Empty;
[ConfigKey(description: "Request timeout", defaultValue: "00:00:30")]
public TimeSpan Timeout { get; set; }
}
The class is bound automatically — no explicit IOptions<PaymentsOptions> registration is required. Consumption is standard:
public sealed class CheckoutService(IOptionsMonitor<PaymentsOptions> options)
{
public Task ChargeAsync()
{
var snapshot = options.CurrentValue;
// ...
}
}
Public API
| Type / method | Purpose |
|---|---|
ConfigurationBuilderExtensions.AddRealtimeConfig() |
Adds the gRPC-backed configuration source to IConfigurationBuilder. |
ServiceCollectionExtensions.AddRealtimeConfig() |
Registers the hosted service, options bindings, and infrastructure services. |
ServiceCollectionExtensions.AddRtcOptions() |
Binds discovered [ConfigGroup] classes to their IOptions<T> sections. |
Failure modes
- When
IsEnabled = falsethe hosted service parks onTask.Delay(Infinite)and stays idle. - If no class annotated with
[ConfigGroup]is found, the service logs a warning and does not start. This is a safe no-op rather than a host crash. - When the subscription stream drops, the service waits for
PollingIntervaland re-establishes the subscription. The localtimestampis preserved so it resumes from where it left off after a reconnect. - Events with
Generation == 1are treated as the initial state and do not overwrite data already loaded via the initial snapshot.
Related packages
Konfigo.Abstraction— theConfigGroup/ConfigKeyattributes.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Google.Protobuf (>= 3.35.0)
- Grpc.Net.ClientFactory (>= 2.80.0)
- Konfigo.Abstraction (>= 0.0.4)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.8)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Http.Polly (>= 10.0.8)
- Microsoft.Extensions.Logging (>= 10.0.8)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.8)
- Polly (>= 8.6.6)
- StronglyTypedId (>= 0.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial 0.0.4 release.