Skip to content

Commit

Permalink
WaitFor PR feedback (#5500)
Browse files Browse the repository at this point in the history
Follow up feedback for #5394.
  • Loading branch information
eerhardt authored Aug 31, 2024
1 parent c973ace commit 84bd9f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ public static class KnownResourceStates
/// <summary>
/// List of terminal states.
/// </summary>
public static readonly string[] TerminalStates = [Finished, FailedToStart, Exited];
public static readonly IReadOnlyList<string> TerminalStates = [Finished, FailedToStart, Exited];
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,19 @@ public async Task<string> WaitForResourceAsync(string resourceName, IEnumerable<
}

/// <summary>
/// Waits for a resource to reach one of the specified states. See <see cref="KnownResourceStates"/> for common states.
/// Waits until a resource satisfies the specified predicate.
/// </summary>
/// <remarks>
/// This method returns a task that will complete when the resource reaches one of the specified target states. If the resource
/// is already in the target state, the method will return immediately.<br/>
/// If the resource doesn't reach one of the target states before <paramref name="cancellationToken"/> is signaled, this method
/// This method returns a task that will complete when the specified predicate returns <see langword="true" />.<br/>
/// If the predicate isn't satisfied before <paramref name="cancellationToken"/> is signaled, this method
/// will throw <see cref="OperationCanceledException"/>.
/// </remarks>
/// <param name="resourceName">The name of the resource.</param>
/// <param name="predicate">A predicate which is evaluated for each <see cref="ResourceEvent"/> for the selected resource.</param>
/// <param name="cancellationToken">A cancellation token that cancels the wait operation when signaled.</param>
/// <returns>A <see cref="Task{ResourceEvent}"/> representing the wait operation and which of the target states the resource reached.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters",
Justification = "targetState(s) parameters are mutually exclusive.")]
Justification = "predicate and targetState(s) parameters are mutually exclusive.")]
public async Task<ResourceEvent> WaitForResourceAsync(string resourceName, Func<ResourceEvent, bool> predicate, CancellationToken cancellationToken = default)
{
using var watchCts = CancellationTokenSource.CreateLinkedTokenSource(_applicationStopping, cancellationToken);
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Hosting/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ static Aspire.Hosting.ContainerResourceBuilderExtensions.WithBuildArg<T>(this As
static Aspire.Hosting.ContainerResourceBuilderExtensions.WithBuildSecret<T>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T!>! builder, string! name, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource!>! value) -> Aspire.Hosting.ApplicationModel.IResourceBuilder<T!>!
static Aspire.Hosting.ProjectResourceBuilderExtensions.AddProject(this Aspire.Hosting.IDistributedApplicationBuilder! builder, string! name, string! projectPath, System.Action<Aspire.Hosting.ProjectResourceOptions!>! configure) -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ProjectResource!>!
static Aspire.Hosting.ProjectResourceBuilderExtensions.AddProject<TProject>(this Aspire.Hosting.IDistributedApplicationBuilder! builder, string! name, System.Action<Aspire.Hosting.ProjectResourceOptions!>! configure) -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ProjectResource!>!
static readonly Aspire.Hosting.ApplicationModel.KnownResourceStates.TerminalStates -> string![]!
static readonly Aspire.Hosting.ApplicationModel.KnownResourceStates.TerminalStates -> System.Collections.Generic.IReadOnlyList<string!>!
static readonly Aspire.Hosting.ApplicationModel.KnownResourceStates.Waiting -> string!

0 comments on commit 84bd9f7

Please sign in to comment.