Skip to content

feat: add custom Orleans provider type annotation#13630

Open
flensrocker wants to merge 2 commits intodotnet:mainfrom
flensrocker:orleans-provider-type
Open

feat: add custom Orleans provider type annotation#13630
flensrocker wants to merge 2 commits intodotnet:mainfrom
flensrocker:orleans-provider-type

Conversation

@flensrocker
Copy link

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:

var garnet = builder.AddGarnet("garnet")
                    .WithOrleansProviderType("Redis");

var orleans = builder.AddOrleans()
                     .WithClustering(garnet);

Fixes dotnet/orleans#9848

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No (I didn't find a related test project)
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

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);
```
@github-actions
Copy link
Contributor

github-actions bot commented Dec 18, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13630

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13630"

@davidfowl
Copy link
Member

@ReubenBond can you review plz

const string resource = "Resource";
var serviceKey = resourceBuilder.Resource.Name;

if (resourceBuilder.Resource.TryGetAnnotationsOfType<OrleansProviderTypeAnnotation>(out var annotations) && annotations.FirstOrDefault() is OrleansProviderTypeAnnotation annotation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will address that!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed something - let me know if it's what you had in mind.
And also if I should rebase/squash on current main.

@flensrocker flensrocker force-pushed the orleans-provider-type branch from 2f72227 to 07c2620 Compare March 5, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Garnet as a replacement for Redis with Aspire/ServiceDiscovery

3 participants