-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace health check publisher and scheduler with ResourceHealthCheck…
…Service and introduce ResourceReadyEvent. (#5870) * Raise ResourceHealthyEvent. * Control dispatch of events. * Use HashSet * Unit tests for blocking/nonblock/sequential/concurrent tests. * Make sure health checks don't run after entering a health state. * Disable failing mongo test. * WIP - reworking things a bit. * Working (not optimized) * Add tracing. * Cleaning up tests. * PR feedback. * Tests! * Slow down health checks on resources in a stable state. * Move resourcesStartedMonitoring into a local variable. * Update src/Aspire.Hosting/Health/ResourceHealthCheckService.cs Co-authored-by: David Fowler <[email protected]> * Update src/Aspire.Hosting/Health/ResourceHealthCheckService.cs Co-authored-by: David Fowler <[email protected]> * do-while * Don't crash out when a poor health check is registered. --------- Co-authored-by: David Fowler <[email protected]>
- Loading branch information
1 parent
f7f20e4
commit 94008ce
Showing
24 changed files
with
825 additions
and
159 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
27 changes: 27 additions & 0 deletions
27
src/Aspire.Hosting/ApplicationModel/ResourceHealthyEvent.cs
This file contains 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,27 @@ | ||
// 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.Eventing; | ||
|
||
namespace Aspire.Hosting.ApplicationModel; | ||
|
||
/// <summary> | ||
/// Event that is raised when a resource initially transitions to a ready state. | ||
/// </summary> | ||
/// <param name="resource">The resource that is in a ready state.</param> | ||
/// <param name="services">The service provider for the app host.</param> | ||
/// <remarks> | ||
/// This event is only fired once per resource the first time it transitions to a ready state. | ||
/// </remarks> | ||
public class ResourceReadyEvent(IResource resource, IServiceProvider services) : IDistributedApplicationResourceEvent | ||
{ | ||
/// <summary> | ||
/// The resource that is in a healthy state. | ||
/// </summary> | ||
public IResource Resource => resource; | ||
|
||
/// <summary> | ||
/// The service provider for the app host. | ||
/// </summary> | ||
public IServiceProvider Services => services; | ||
} |
This file contains 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 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 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 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 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 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,30 @@ | ||
// 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.Eventing; | ||
|
||
/// <summary> | ||
/// Controls how events are dispatched to subscribers. | ||
/// </summary> | ||
public enum EventDispatchBehavior | ||
{ | ||
/// <summary> | ||
/// Fires events sequentially and blocks until they are all processed. | ||
/// </summary> | ||
BlockingSequential, | ||
|
||
/// <summary> | ||
/// Fires events concurrently and blocks until they are all processed. | ||
/// </summary> | ||
BlockingConcurrent, | ||
|
||
/// <summary> | ||
/// Fires events sequentially but does not block. | ||
/// </summary> | ||
NonBlockingSequential, | ||
|
||
/// <summary> | ||
/// Fires events concurrently but does not block. | ||
/// </summary> | ||
NonBlockingConcurrent | ||
} |
This file contains 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
Oops, something went wrong.