Skip to content

Tightening the resource lifecycle #9146

Open
@DamianEdwards

Description

@DamianEdwards

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<TResource> if adding resources)
    • IDistibutedApplicationLifecycleHook.BeforeStartAsync
    • NEW EVENT: IDistributedApplicationEventing -> InitializeResourceEvent
    • IDistributedApplicationEventing -> EndpointsAllocatedEvent
    • IDistibutedApplicationLifecycleHook.EndpointsAllocatedAsync
    • Per DCP controlled resources:
      • IDistributedApplicationEventing -> ConnectionStringAvailableEvent
      • IDistributedApplicationEventing -> BeforeResourceStartedEvent
        • This even 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions