Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
Currently you can wait for a service to become healthy, or become healthy. In some cases it would also be beneficial to wait until a service starts. This is particularly true for initalisation type code that may be required to run before the health checks can pass.
Describe the solution you'd like
I'd like to see some WaitForStart
methods, which mirror the existing WaitFor
methods - the only difference is these only wait for the resource to enter the Running
state, as opposed to waiting for health checks to pass. If a resource has no health checks defined, the two methods will behave identically.
namespace Aspire.Hosting;
public static class ResourceBuilderExtensions
{
//...
public static IResourceBuilder<T> WaitFor<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency) where T : IResourceWithWaitSupport
public static IResourceBuilder<T> WaitFor<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior waitBehavior) where T : IResourceWithWaitSupport
public static IResourceBuilder<T> WaitForCompletion<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, int exitCode = 0) where T : IResourceWithWaitSupport
+ public static IResourceBuilder<T> WaitForStart<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency) where T : IResourceWithWaitSupport
+ public static IResourceBuilder<T> WaitForStart<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior waitBehavior) where T : IResourceWithWaitSupport
//...
}
Additional context
This would align Aspire's wait for options with the conditions docker compose supports in it's depends_on
condition
: Sets the condition under which dependency is considered satisfied
service_started
: An equivalent of the short syntax described aboveservice_healthy
: Specifies that a dependency is expected to be "healthy"
(as indicated by healthcheck) before starting a dependent
service.service_completed_successfully
: Specifies that a dependency is expected to run
to successful completion before starting a dependent service.
https://github.com/compose-spec/compose-spec/blob/main/05-services.md#depends_on