Skip to content

Add optional parameter to configuration providers for non-blocking startup#1844

Merged
WhitWaldo merged 12 commits into
masterfrom
config-providers-optional-startup
Jun 5, 2026
Merged

Add optional parameter to configuration providers for non-blocking startup#1844
WhitWaldo merged 12 commits into
masterfrom
config-providers-optional-startup

Conversation

@WhitWaldo

Copy link
Copy Markdown
Contributor

Description

Completion of work started in #1745

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #1748

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

GeorgeTsiokos and others added 7 commits June 5, 2026 06:33
…artup

Configuration and secret store providers now accept an `optional` parameter
that allows applications to start without blocking on sidecar availability.
When optional, configuration loads in the background with resilient retry
logic that handles transient Dapr errors gracefully.

- Add `optional` parameter to AddDaprConfigurationStore and AddDaprSecretStore
- Harden LoadInBackgroundAsync to catch OperationCanceledException and
  DaprException separately, avoiding silent swallowing of programming errors
- Dispose CancellationTokenSource in both providers to prevent resource leaks
- Fix StringComparer inconsistency (InvariantCultureIgnoreCase → OrdinalIgnoreCase)
- Mark fields readonly in DaprConfigurationStoreProvider for consistency
- Restore UTF-8 BOM per .editorconfig and add missing trailing newlines
- Add deterministic tests using reload tokens instead of fragile Task.Delay

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: George Tsiokos <george@tsiokos.com>
Tests verify three scenarios using secretstores.local.file (no external deps):
- optional:true with delayed sidecar: config populates once sidecar starts
- optional:false (default): Build() blocks until sidecar ready, secrets populated
- Disposal during background load: exits cleanly with no hang

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: George Tsiokos <george@tsiokos.com>
…s around Count

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
…kground tasks have started may cause ObjectDisposedException races

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
… instead of calling `Set` repeatedly

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.05376% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.55%. Comparing base (b93cf3c) to head (b70fde0).

Files with missing lines Patch % Lines
...apr.Testcontainers/Harnesses/SecretStoreHarness.cs 0.00% 30 Missing ⚠️
...ns.Configuration/DaprConfigurationStoreProvider.cs 71.42% 20 Missing and 2 partials ⚠️
...figuration/DaprSecretStoreConfigurationProvider.cs 83.92% 6 Missing and 3 partials ⚠️
...guration/DaprSecretStoreConfigurationExtensions.cs 83.33% 2 Missing ⚠️
...c/Dapr.Testcontainers/Common/DaprHarnessBuilder.cs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1844      +/-   ##
==========================================
+ Coverage   63.46%   63.55%   +0.09%     
==========================================
  Files         312      313       +1     
  Lines        9279     9431     +152     
  Branches     1101     1106       +5     
==========================================
+ Hits         5889     5994     +105     
- Misses       3130     3175      +45     
- Partials      260      262       +2     
Flag Coverage Δ
net10.0 63.54% <65.05%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add optional parameter to configuration providers

2 participants