Skip to content

Conversation

@OmnipotentOwl
Copy link
Contributor

@OmnipotentOwl OmnipotentOwl commented Oct 26, 2024

PR Classification

New feature: Introduce support for Cosmos DB clustering provider for Orleans via Microsoft.Extensions.Configuration.

PR Summary

This pull request supports the Cosmos DB clustering provider for Orleans to be configured via Microsoft.Extensions.Configuration, enabling clustering configurations for both Silo and Client roles.

  • CosmosClusteringProviderBuilder.cs: Implemented the CosmosClusteringProviderBuilder class and registered it as a provider.
  • CosmosClusteringOptions.cs: Introduced CosmosClusteringOptions and a validator class.
  • AssemblyInfo.cs: Added [assembly: InternalsVisibleTo("Tester.AzureUtils")] attribute.
Microsoft Reviewers: Open in CodeFlow

@OmnipotentOwl
Copy link
Contributor Author

@dotnet-policy-service agree

@ReubenBond
Copy link
Member

Is this ready for review?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

@OmnipotentOwl
Copy link
Contributor Author

@ReubenBond I believe it is, however I would want to run the pipelines again to ensure there aren't any hidden issues.

@ReubenBond ReubenBond force-pushed the feature/cosmos-cluster-iconfiguration branch from bf98daf to ff3874c Compare February 13, 2025 17:28
@ReubenBond
Copy link
Member

@OmnipotentOwl I rebased and am re-running workflows. Ideally, we should update the tests to use this new configuration mechanism

@OmnipotentOwl OmnipotentOwl marked this pull request as ready for review February 23, 2025 04:27
@OmnipotentOwl
Copy link
Contributor Author

@ReubenBond, I did some local testing with Aspire with the clustering configuration, and it looks to work mostly for the Cosmos DB emulator (next). I did have to adjust the assembly: RegisterProvider name property based on what I saw in Aspire, but if you feel like we shouldn't rename that or name it just 'Cosmos,' then we might need to do a shim in Aspire to handle that difference.

I am going to see if I can run it tomorrow against a real Cosmos DB instance and if that looks good I may have another PR here shortly for the storage provider.

Added a `using` directive for `System.Runtime.CompilerServices` and
an assembly attribute `[assembly: InternalsVisibleTo("Tester.AzureUtils")]`
to make internal types visible to the `Tester.AzureUtils` assembly.
Introduce CosmosClusteringProviderBuilder class implementing IProviderBuilder<ISiloBuilder> and IProviderBuilder<IClientBuilder> interfaces. Register the class as a provider for both "Silo" and "Client" roles. Implement Configure methods to set up Cosmos DB clustering options and client configuration. Import necessary namespaces to support the new functionality.

This adds support for using the Cosmos DB Clustering Provider from Orleans IConfiguration setup.
Replaced "Cosmos" with "AzureCosmosDB" in the
assembly registrations for the `CosmosClusteringProviderBuilder`
for both "Silo" and "Client" configurations to better reflect the
configuration values used by Aspire.
@ReubenBond ReubenBond force-pushed the feature/cosmos-cluster-iconfiguration branch from 038fd6a to 05ae7af Compare March 20, 2025 21:16
@ReubenBond
Copy link
Member

LGTM - I tested with Aspire, using this config:

var builder = DistributedApplication.CreateBuilder(args);

var cosmosDb = builder.AddAzureCosmosDB("cosmos-clustering").RunAsEmulator();
var db = cosmosDb.AddCosmosDatabase("Orleans").AddContainer("OrleansCluster", "/ClusterId");

var orleans = builder.AddOrleans("cluster")
    .WithClustering(cosmosDb);

builder.AddProject<DashboardToy_Frontend>("frontend")
    .WithReference(orleans)
    .WithReference(db)
    .WaitFor(db)
    .WaitFor(cosmosDb)
    .WithReplicas(5);

builder.Build().Run();

@ReubenBond
Copy link
Member

It did not work with the vNext emulator for me - seemingly due to this issue, based on the error message: Azure/azure-cosmos-db-emulator-docker#170

@ReubenBond ReubenBond enabled auto-merge (squash) March 20, 2025 21:20
@ReubenBond ReubenBond changed the title Microsoft.Extensions.Configuration support for Cosmos Clustering Provider IConfiguration support for Azure Cosmos DB Clustering Provider Mar 20, 2025
@ReubenBond ReubenBond disabled auto-merge March 20, 2025 21:21
@ReubenBond ReubenBond merged commit f24a7cc into dotnet:main Mar 20, 2025
23 of 25 checks passed
@OmnipotentOwl OmnipotentOwl deleted the feature/cosmos-cluster-iconfiguration branch March 21, 2025 12:41
@github-actions github-actions bot locked and limited conversation to collaborators Apr 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants