Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 13, 2025

  • Add new ResourceStartedEvent class that fires after resource starts but before health checks
  • Implement event firing in ResourceHealthCheckService when resource enters Running state
  • Add extension method OnResourceStarted for easy event subscription
  • Create basic test for ResourceStartedEvent properties
  • Move ResourceStartedEvent firing logic inside MonitorResourceHealthAsync method (addresses review feedback)

Changes Made:

  • New Event Class: ResourceStartedEvent that implements IDistributedApplicationResourceEvent
  • Event Timing: Fires immediately when resource state transitions to "Running", before health check monitoring begins
  • Public API: Extension method OnResourceStarted for easy event subscription
  • Test Coverage: Basic test to verify event properties are correctly set
  • Code Organization: Event firing logic moved into MonitorResourceHealthAsync for better encapsulation

Benefits:

  • Provides immediate feedback when resources start successfully
  • Fills timing gap between BeforeResourceStartedEvent and ResourceReadyEvent
  • Enables faster status updates for dependent resources (like dev tunnels)
  • Follows consistent patterns with existing resource events

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.

}

// Fire the ResourceStartedEvent before health check monitoring begins
_ = Task.Run(async () =>
Copy link
Member

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

Copy link
Contributor Author

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)

@Copilot Copilot AI changed the title [WIP] Add new ResourceStartedEvent Add new ResourceStartedEvent that fires after resource starts but before health checks Sep 13, 2025
@Copilot Copilot AI requested a review from davidfowl September 13, 2025 07:47
Copilot finished work on behalf of davidfowl September 13, 2025 07:47
Copilot finished work on behalf of davidfowl September 13, 2025 08:00
Copy link
Contributor

🚀 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 -- 11381

Or

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

@davidfowl davidfowl marked this pull request as ready for review September 13, 2025 20:42
@Copilot Copilot AI review requested due to automatic review settings September 13, 2025 20:42
Copy link
Contributor

@Copilot 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.

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 implementing IDistributedApplicationResourceEvent
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants