microsoft / microsoft/aspire

Tightening the resource lifecycle

Open
#9,146 10 comments 1 reaction 0 assignees View on GitHub
area-app-model
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

Current runtime lifecycle processing:

- `DistributedApplication.StartAsync`
- `IDistributedApplicationEventing -> BeforeStartEvent`
- The `DistributedApplication.Services` collection is built by the time this event is published
- This event is the last chance to add or remove resources from the `DistributedApplicationModel` before they're processed by consumers (note you'll likely want to capture the `IDistributedApplicationBuilder` before this so that you can get instances of `IResourceBuilder` if adding resources)
- `IDistibutedApplicationLifecycleHook.BeforeStartAsync`
- *NEW EVENT*: `IDistributedApplicationEventing -> InitializeResourceEvent`
- `IDistributedApplicationEventing -> EndpointsAllocatedEvent`
- `IDistibutedApplicationLifecycleHook.EndpointsAllocatedAsync`
- *NEW EVENT* Per resource: `IDistributedApplicationEventing -> ResourceEndpointsAllocatedEvent`
- Processing for resource URLs, including invoking callbacks, is done on this event
- Per DCP controlled resources:
- `IDistributedApplicationEventing -> ConnectionStringAvailableEvent`
- `IDistributedApplicationEventing -> BeforeResourceStartedEvent`
- This event can be fired multiple times for a resource, e.g. if it's restarted it will fire each time before it starts
- This event is the last chance to mutate a resource's annotations before they're processed by consumers
- The logic for `WaitFor` is implemented here, so resources must publish this event
- `IDistributedApplicationEventing -> ResourceReadyEvent`
- fires for all resources after health checks are healthy, only once
- Resources that have a `WaitFor` relationship to another resource are waiting for this event
- `IDistributedApplicationEventing -> AfterResourcesCreatedEvent`
- `IDistibutedApplicationLifecycleHook.AfterResourcesCreatedAsync`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.