-
Notifications
You must be signed in to change notification settings - Fork 684
Add WaitForResourceReadyAsync method with WaitBehavior support and integrate with ResourceNotificationService #10849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
c409042
9ee357d
05ee2e1
a71af20
8e9d437
5fc62ac
e3545cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,6 +247,39 @@ public async Task<ResourceEvent> WaitForResourceHealthyAsync(string resourceName | |
cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// Waits for a resource to be ready. | ||
/// </summary> | ||
/// <param name="resourceName">The name of the resource.</param> | ||
/// <param name="cancellationToken">The cancellation token.</param> | ||
/// <returns>A task.</returns> | ||
/// <remarks> | ||
/// <para> | ||
/// This method returns a task that will complete when the resource's ResourceReadyEvent | ||
/// is present and its associated EventTask has completed. This allows developers using | ||
/// the lower-level API to fine-tune what lifecycle event they wait for. | ||
/// </para> | ||
/// <para> | ||
/// If the resource doesn't have a ResourceReadyEvent or if the EventTask doesn't complete | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot this paragraph is incorrect. There should always be a ResourceReadyEvent. However we should probably remove this remarks section because it is referring to the ResourceReadyEvent internal field, not the class. Instead simply have a paragraph in remarks that notes that this method returns a task that completes when all subscriptions to the ResourceReadyEvent have completed (if any). If any throw an exception, this method will throw an exception. If none are present this method will return immediately. Also add a paragraph that notes that this method does not explicitly wait for the resource to be healthy and that it can be used independently of or together with the WaitForResourceHealthyAsync method. Add a matching comment to the remarks for the WaitForResourceHealthyAsync method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the documentation as requested. The WaitForResourceReadyAsync remarks now correctly explain that it completes when all subscriptions to the ResourceReadyEvent have completed, and added relationship notes to both WaitForResourceHealthyAsync method overloads. Commit: a71af20 |
||
/// before <paramref name="cancellationToken"/> is signaled, this method will throw | ||
/// <see cref="OperationCanceledException"/>. | ||
/// </para> | ||
/// </remarks> | ||
public async Task<ResourceEvent> WaitForResourceReadyAsync(string resourceName, CancellationToken cancellationToken = default) | ||
{ | ||
_logger.LogDebug("Waiting for resource '{Name}' to be ready.", resourceName); | ||
|
||
// First wait for the ResourceReadyEvent to be present | ||
var resourceEvent = await WaitForResourceCoreAsync(resourceName, re => re.Snapshot.ResourceReadyEvent is not null, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
|
||
// Then await the EventTask to complete | ||
await resourceEvent.Snapshot.ResourceReadyEvent!.EventTask.WaitAsync(cancellationToken).ConfigureAwait(false); | ||
|
||
_logger.LogDebug("Finished waiting for resource '{Name}' to be ready.", resourceName); | ||
|
||
return resourceEvent; | ||
} | ||
|
||
/// <summary> | ||
/// Waits for a resource to become healthy. | ||
/// </summary> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value documentation is incomplete. It should specify that it returns 'A task that completes with a ResourceEvent when the resource is ready.' to be consistent with the WaitForResourceHealthyAsync method documentation.
Copilot uses AI. Check for mistakes.