-
Notifications
You must be signed in to change notification settings - Fork 690
Add new ResourceStartedEvent that fires after resource starts but before health checks #11381
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
base: main
Are you sure you want to change the base?
Conversation
…althCheckService Co-authored-by: davidfowl <[email protected]>
} | ||
|
||
// Fire the ResourceStartedEvent before health check monitoring begins | ||
_ = Task.Run(async () => |
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.
@copilot move this logic inside of MonitorResourceHealthAsync
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.
Done! I've moved the ResourceStartedEvent firing logic inside MonitorResourceHealthAsync method. The event is now fired at the very beginning of the health monitoring process, which provides better encapsulation and consolidates all the health monitoring logic in one place. (commit c3e7b8c)
…d basic test Co-authored-by: davidfowl <[email protected]>
ResourceStartedEvent
…c method Co-authored-by: davidfowl <[email protected]>
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11381 Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11381" |
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 ResourceStartedEvent
that fills the timing gap between when a resource starts and when health checks complete. The event fires immediately when a resource transitions to "Running" state, enabling faster status updates for dependent resources.
Key changes:
- Adds
ResourceStartedEvent
class implementingIDistributedApplicationResourceEvent
- Fires the event in
MonitorResourceHealthAsync
before health check monitoring begins - Provides
OnResourceStarted
extension method for easy event subscription
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/Aspire.Hosting/ApplicationModel/ResourceStartedEvent.cs | New event class that fires when resource starts but before health checks |
src/Aspire.Hosting/Health/ResourceHealthCheckService.cs | Implements event firing logic in MonitorResourceHealthAsync method |
src/Aspire.Hosting/DistributedApplicationEventingExtensions.cs | Adds OnResourceStarted extension method for event subscription |
tests/Aspire.Hosting.Tests/Health/ResourceHealthCheckServiceTests.cs | Basic test to verify ResourceStartedEvent properties |
Changes Made:
ResourceStartedEvent
that implementsIDistributedApplicationResourceEvent
OnResourceStarted
for easy event subscriptionMonitorResourceHealthAsync
for better encapsulationBenefits:
BeforeResourceStartedEvent
andResourceReadyEvent
The ResourceStartedEvent is now fired at the beginning of the
MonitorResourceHealthAsync
method, consolidating all health monitoring logic in one place.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.