Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register Dapr services in keyed-compatible manner #1238

Merged
merged 3 commits into from
Feb 16, 2024

Conversation

philliphoff
Copy link
Contributor

Description

.NET 8 adds the ability to register "keyed" services with a service collection. The implementation of this feature, however, breaks how many existing components look through that service collection to determine whether they've been previously registered (a common if, perhaps, now an anti-pattern with the advent of TryAddSingleton()). If a component registers a keyed service before another component performs such a search, that search cause an exception to be thrown.

The Dapr .NET SDK uses this "old" style of registering "marker" services to help prevent multiple registrations, which triggers this new behavior in .NET 8. This change switches to the newer TryAddSingleton() approach to avoid that problem.

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: #1235

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

Signed-off-by: Phillip Hoff <phillip@orst.edu>
@philliphoff philliphoff requested review from a team as code owners February 15, 2024 19:14
Copy link

codecov bot commented Feb 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (83858d7) 67.36% compared to head (4225d98) 67.28%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1238      +/-   ##
==========================================
- Coverage   67.36%   67.28%   -0.09%     
==========================================
  Files         174      174              
  Lines        6028     6025       -3     
  Branches      672      671       -1     
==========================================
- Hits         4061     4054       -7     
- Misses       1800     1802       +2     
- Partials      167      169       +2     
Flag Coverage Δ
net6 67.26% <100.00%> (-0.09%) ⬇️
net7 67.26% <100.00%> (-0.09%) ⬇️
net8 67.27% <100.00%> (-0.09%) ⬇️

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

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

@philliphoff
Copy link
Contributor Author

@halspang Would appreciate a quick review when you have a chance, thanks!

@rliberoff
Copy link

Hello!

I hope this helps: from further investigation, we found out that the offending dependency is with library Microsoft.Extensions.Http.Resilience when updated from version 8.1.0 to 8.2.0. Hope it helps.

When using that library, the AddDaprClient throws the exception that is mentioned in the issue.

My Team and I really appreciete your effor guys for providing an update for this. Thank you.

@onionhammer
Copy link
Contributor

When is this getting released (non-preview)?

@philliphoff
Copy link
Contributor Author

When is this getting released (non-preview)?

@onionhammer It will be released as part of the larger Dapr 1.13 release, coming very soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AddDaprClient incompatible with keyed services
4 participants