WaitFor/WaitForCompletion implementation.#5394
Merged
mitchdenny merged 12 commits intomainfrom Aug 30, 2024
Merged
Conversation
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
davidfowl
reviewed
Aug 23, 2024
Co-authored-by: David Fowler <davidfowl@gmail.com>
davidfowl
reviewed
Aug 23, 2024
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
davidfowl
reviewed
Aug 28, 2024
davidfowl
reviewed
Aug 28, 2024
Open
3 tasks
davidfowl
reviewed
Aug 28, 2024
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
davidfowl
reviewed
Aug 28, 2024
| /// </example> | ||
| public static IResourceBuilder<T> WaitFor<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency) where T : IResource | ||
| { | ||
| builder.ApplicationBuilder.Eventing.Subscribe<BeforeResourceStartedEvent>(builder.Resource, async (e, ct) => |
Contributor
There was a problem hiding this comment.
Another downside to doing it this way instead of a single wait for callback with lots of data is that first one to throw will stop other errors from coming through since the wait is sequential.
Member
Author
There was a problem hiding this comment.
Maybe for this event we should invoke them all in parallel and then await them all together.
…ils before going into a running state.
Member
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
davidfowl
approved these changes
Aug 30, 2024
eerhardt
added a commit
to eerhardt/aspire
that referenced
this pull request
Aug 30, 2024
Follow up feedback for microsoft#5394.
Merged
davidfowl
pushed a commit
that referenced
this pull request
Aug 31, 2024
Follow up feedback for #5394.
15 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces two new extension APIs to the
IResourceBuilder<T>interface:namespace Aspire.Hosting; public class ResourceBuilderExtensions { + public static IResourceBuilder<T> WaitFor<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency) where T : IResource + public static IResourceBuilder<T> WaitForCompletion<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency) where T : IResource }Using these APIs it is possible to block the start of one resource depending on the start or completion of another resource.
The
WaitFor(...)extension will wait until the resource enters theRunningstate, and theWaitForCompletionwill wait until it is in theFinishedstate.The
WaitFor/WaitForCompletionmethods build upon the eventing mechanism that was recently added. It waits for the resource started event and then uses theResourceNotificationservice to wait until the resource reaches the desired state. In a subsequent PR we will build on this to support waiting until the resource is healthy in addition to just being in a running state.Resources in a waiting state will have their state changed to
Waitingwith the same iconography as Starting (hence the small changes to dashboard/known state code).Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?Microsoft Reviewers: Open in CodeFlow