-
Couldn't load subscription status.
- Fork 713
Add IResourceBuilder<T> extension method for event subscriptions
#10097
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
Conversation
Add a number of extension method on `IResourceBuilder<T>` to easily subscribe to `IDistributedApplicationResourceEvent` on a resource Refactored a few subscription calls over to use the new methods - at least one for each event
IResourceBuilder<T> extension method for event subscriptions
|
We're trying to decide When* vs On* |
|
Yeah, I think I think what we want is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new set of extension methods on IResourceBuilder for event subscriptions and refactors existing subscriptions across various resource builders to use these extensions. Key changes include the creation of new event subscription extension methods, refactoring of subscription calls in SQL Server, Azure, CosmosDB, and custom resource code, and updates to fluent API chaining.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting/ResourceBuilderExtensions.cs | Refactored event subscriptions to use the new extension methods. |
| src/Aspire.Hosting/EventingExtensions.cs | Added new extension methods for event subscriptions. |
| src/Aspire.Hosting.SqlServer/SqlServerBuilderExtensions.cs | Updated SQL Server resource builder to chain event subscriptions. |
| src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs | Refactored Azure Storage event subscription calls. |
| src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBExtensions.cs | Refactored CosmosDB subscription and iterated over database collection. |
| src/Aspire.Hosting.Azure.AIFoundry/AzureAIFoundryExtensions.cs | Updated custom resource subscriptions to use the extension methods. |
| playground/mongo/Mongo.AppHost/Program.cs | Refactored MongoDB subscription to use the new event extension method. |
| playground/CustomResources/CustomResources.AppHost/TalkingClockResource.cs | Updated custom resource initialization and event handling. |
Comments suppressed due to low confidence (1)
src/Aspire.Hosting/EventingExtensions.cs:15
- The XML documentation for OnBeforeResourceStarted contains an extraneous quotation mark and trailing '/>' at the end. Consider removing these characters for clarity.
/// Subscribes a callback to the <see cref="BeforeResourceStartedEvent"/> event within the AppHost."/>
| }); | ||
|
|
||
| CosmosClient? cosmosClient = null; | ||
| builder.OnConnectionStringAvailable(async (cosmosDb, @event, ct) =>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting here is all messed up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! We can do a follow up to finishing consuming these APIs everywhere
- Fix formatting in AzureCosmosDBExtensions - Fix rogue `"/>` in `On*` method xml docs
IResourceBuilder<T> extension method for event subscriptionsIResourceBuilder<T> extension method for event subscriptions
|
Agree with @davidfowl - this was a good idea @afscrome |
Description
Add a number of extension method on
IResourceBuilder<T>to easily subscribe toIDistributedApplicationResourceEventon a resourceRefactored a few subscription calls over to use the new methods. I can refactor more, just wanted to get a small amount (one per event) to prove the concept out.
Fixes #9168
Checklist
.Subscribe<T>over to the new methods<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate