-
Notifications
You must be signed in to change notification settings - Fork 724
WaitFor integration with Health Check Service #5515
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
50808ed
WIP.
mitchdenny f7d199b
WIP
mitchdenny 231e93f
WIP
mitchdenny 5cc25e1
Moved over to using RNS to detecting health.
mitchdenny 50252a9
Connection strings without config.
mitchdenny d9189b0
Add playground for WaitFor.
mitchdenny 65d4eed
Tidy up capture of connection string in Redis.
mitchdenny 8b46ab0
Progress on WaitFor on Azure resource.
mitchdenny f98ccb9
Make HealthStatus null by default.
mitchdenny ee4e611
Remove WaitFor in testshop.
mitchdenny bd3b710
Put project based dashboard back in.
mitchdenny e8d8a42
Added ConnectionStringAvailableEvent and fire from within AppExecutor…
mitchdenny a801683
Forgot Redis extensions.
mitchdenny f115faf
Fix up manifest.
mitchdenny d57f7a3
Health check name.
mitchdenny 4c93885
Keep track of resources and surrogate resources to avoid searches.
mitchdenny bff081e
Get child resources updating correcting in Azure provisioner.
mitchdenny dc6675e
Clean-up playgrounds.
mitchdenny 4a639e6
PR feedback.
mitchdenny 4d95831
WaitFor works on Postgres database resource.
mitchdenny 7973a2c
Add WithHealthCheck.
mitchdenny 86b5f6a
Update RedisBuilderExtensions.cs
mitchdenny e0aceae
Remove whitespace change.
mitchdenny 007c2b6
Merge branch 'mitchdenny/healthcheckintegration' of https://github.co…
mitchdenny 0587773
Throw when connection string not available.
mitchdenny 6652a18
Functional tests.
mitchdenny c55f588
Ignore health check service errors in app host logs for now.
mitchdenny 1f83066
Add some XML doc comments.
mitchdenny 572bcc9
Add remarks to APIs.
mitchdenny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
16 changes: 16 additions & 0 deletions
16
src/Aspire.Hosting/ApplicationModel/HealthCheckAnnotation.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Aspire.Hosting.ApplicationModel; | ||
|
|
||
| /// <summary> | ||
| /// An annotation which tracks the name of the health check used to detect to health of a resource. | ||
| /// </summary> | ||
| /// <param name="key">TODO </param> | ||
| public class HealthCheckAnnotation(string key) : IResourceAnnotation | ||
mitchdenny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| /// <summary> | ||
| /// TODO | ||
mitchdenny marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// </summary> | ||
| public string Key => key; | ||
| } | ||
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
37 changes: 37 additions & 0 deletions
37
src/Aspire.Hosting/Health/ResourceNotificationHealthCheckPublisher.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Aspire.Hosting.ApplicationModel; | ||
| using Microsoft.Extensions.Diagnostics.HealthChecks; | ||
|
|
||
| namespace Aspire.Hosting.Health; | ||
|
|
||
| internal class ResourceNotificationHealthCheckPublisher(DistributedApplicationModel model, ResourceNotificationService resourceNotificationService) : IHealthCheckPublisher | ||
| { | ||
| public async Task PublishAsync(HealthReport report, CancellationToken cancellationToken) | ||
| { | ||
| _ = model; | ||
| _ = resourceNotificationService; | ||
mitchdenny marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| foreach (var resource in model.Resources) | ||
| { | ||
| if (resource.TryGetAnnotationsOfType<HealthCheckAnnotation>(out var annotations)) | ||
| { | ||
| var resourceEntries = report.Entries.Where(e => annotations.Any(a => a.Key == e.Key)); | ||
| var status = resourceEntries.All(e => e.Value.Status == HealthStatus.Healthy) ? HealthStatus.Healthy : HealthStatus.Unhealthy; | ||
|
|
||
| await resourceNotificationService.PublishUpdateAsync(resource, s => s with | ||
| { | ||
| HealthStatus = status | ||
| }).ConfigureAwait(false); | ||
| } | ||
| else | ||
| { | ||
| await resourceNotificationService.PublishUpdateAsync(resource, s => s with | ||
| { | ||
| HealthStatus = HealthStatus.Healthy | ||
| }).ConfigureAwait(false); | ||
| } | ||
| } | ||
mitchdenny marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.