-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add data clients to health check, where a failing data client will pu…
…t the overall API into `Degraded`
- Loading branch information
Showing
8 changed files
with
65 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ public enum DataSources | |
FrcEvents, | ||
BlueAlliance, | ||
FtcEvents, | ||
OrangeAlliance | ||
//OrangeAlliance | ||
} |
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,17 @@ | ||
using FiMAdminApi.Data.Enums; | ||
using Microsoft.Extensions.Diagnostics.HealthChecks; | ||
|
||
namespace FiMAdminApi.Clients; | ||
|
||
public class ClientHealthCheck(IServiceProvider services, DataSources source) : IHealthCheck | ||
{ | ||
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, | ||
CancellationToken cancellationToken = new()) | ||
{ | ||
var dataClient = services.GetKeyedService<IDataClient>(source); | ||
if (dataClient is null) return HealthCheckResult.Degraded("Unable to create instance of client"); | ||
|
||
var result = await dataClient.CheckHealth(); | ||
return result == null ? HealthCheckResult.Healthy() : HealthCheckResult.Degraded(result); | ||
} | ||
} |
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