Skip to content
Prev Previous commit
Next Next commit
switch out console for logger; update cache key name for consistency …
…in servicec
  • Loading branch information
oising committed Oct 18, 2024
commit dddbdf5fea41bfd2715820258e0e697fda2789f7
1 change: 1 addition & 0 deletions playground/dapr/Dapr.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

// console app with no appPort (sender only)
builder.AddProject<Projects.DaprServiceC>("servicec")
.WithReference(stateStore)
.WithDaprSidecar();

#if !SKIP_DASHBOARD_REFERENCE
Expand Down
6 changes: 3 additions & 3 deletions playground/dapr/ServiceC/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace Test
{
public sealed class Worker(DaprClient dapr) : BackgroundService
public sealed class Worker(ILogger<Worker> logger, DaprClient dapr) : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
Expand All @@ -30,9 +30,9 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
while (!stoppingToken.IsCancellationRequested)
{
var state = await dapr.GetStateAsync<string?>(
"statestore", "key", cancellationToken: stoppingToken);
"statestore", "cache", cancellationToken: stoppingToken);

Console.WriteLine($"State: {state ?? "<null>"}");
logger.LogInformation("State: {0}", state ?? "<null>");

await Task.Delay(1000, stoppingToken);
}
Expand Down