dotnet-sdk
dotnet-sdk copied to clipboard
Streaming configuration - updates are not propagated
Expected Behavior
Using IOptionsMonitor<T> I can receive updates from dapr configuration store.
Actual Behavior
I am not receiving updates from the configuration store.
Steps to Reproduce the Problem
This can be reproduced using minimal api app
Project file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\Dapr.Extensions.Configuration\Dapr.Extensions.Configuration.csproj" />
</ItemGroup>
</Project>
Program.cs
using Dapr.Client;
using Dapr.Extensions.Configuration;
using Microsoft.Extensions.Options;
var client = new DaprClientBuilder().Build();
var builder = WebApplication.CreateBuilder(args);
var services = builder.Services;
var configuration = builder.Configuration;
configuration.AddDaprConfigurationStore("redisConfig", new List<string> { "version" }, client, TimeSpan.FromSeconds(20));
configuration.AddStreamingDaprConfigurationStore("redisConfig", new List<string> { "version" }, client, TimeSpan.FromSeconds(20));
services.Configure<MyOptions>(builder.Configuration);
var app = builder.Build();
app.MapGet("/", context =>
{
var config = context.RequestServices.GetRequiredService<IOptionsMonitor<MyOptions>>();
return context.Response.WriteAsJsonAsync(config.CurrentValue.Version);
});
app.Run();
class MyOptions
{
public string Version { get; set; }
}
By periodically quering this endpoint while updating the key in redis, the response shculd report updated value, which is not happening and the first value is reported.
EDIT: I've found the root cause and created #935