feat: add custom Orleans provider type annotation#13630
Open
flensrocker wants to merge 2 commits intodotnet:mainfrom
Open
feat: add custom Orleans provider type annotation#13630flensrocker wants to merge 2 commits intodotnet:mainfrom
flensrocker wants to merge 2 commits intodotnet:mainfrom
Conversation
The algorithm of deriving the provider type from the resource type name does not work in every case.
For example, if you want to use Garnet as a drop-in replacement for Redis,
Orleans does not find the corrent provider builder, because there is none defined for "Garnet".
With the new `OrleansProviderTypeAnnotation`, users can explicitly specify the provider type to use for a given resource.
Example:
```
var garnet = builder.AddGarnet("garnet")
.WithOrleansProviderType("Redis");
var orleans = builder.AddOrleans()
.WithClustering(garnet);
```
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13630Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13630" |
Member
|
@ReubenBond can you review plz |
ReubenBond
reviewed
Mar 5, 2026
| const string resource = "Resource"; | ||
| var serviceKey = resourceBuilder.Resource.Name; | ||
|
|
||
| if (resourceBuilder.Resource.TryGetAnnotationsOfType<OrleansProviderTypeAnnotation>(out var annotations) && annotations.FirstOrDefault() is OrleansProviderTypeAnnotation annotation) |
Member
There was a problem hiding this comment.
It would be cleaner to extract out a private static helper method to get the provider type name and only have one return statement in this method. Also we should validate that the provider name isn't null or empty at construction time. Otherwise lgtm. Thanks for the contribution, @flensrocker!
Author
There was a problem hiding this comment.
Thanks, I will address that!
Author
There was a problem hiding this comment.
I pushed something - let me know if it's what you had in mind.
And also if I should rebase/squash on current main.
2f72227 to
07c2620
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The algorithm of deriving the provider type from the resource type name does not work in every case. For example, if you want to use Garnet as a drop-in replacement for Redis, Orleans does not find the corrent provider builder, because there is none defined for "Garnet".
With the new
OrleansProviderTypeAnnotation, users can explicitly specify the provider type to use for a given resource.Example:
Fixes dotnet/orleans#9848
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplate