-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DbContextChecks to Health Checks
This will ensure that the /healthcheck endpoint correctly reports the status of the service if a database connection faults
- Loading branch information
1 parent
70ee728
commit 455d5d6
Showing
9 changed files
with
48 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,6 @@ | |
|
||
logger.LogInformation("Logger is working..."); | ||
|
||
app.MapHealthChecks("/HealthCheck").AllowAnonymous(); | ||
|
||
app.Run(); |
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,16 @@ | ||
using Dfe.Academies.Infrastructure; | ||
|
||
namespace PersonsApi.Setup; | ||
|
||
public static class HealthCheckSetup | ||
{ | ||
public static void AddHealthChecks(IServiceCollection services) { | ||
services.AddHealthChecks(); | ||
AddDbHealthChecks(services); | ||
} | ||
|
||
public static void AddDbHealthChecks(IServiceCollection services) { | ||
services.AddHealthChecks() | ||
.AddDbContextCheck<MstrContext>("Academies Database"); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -37,4 +37,6 @@ | |
|
||
logger.LogInformation("Logger is working..."); | ||
|
||
app.MapHealthChecks("/HealthCheck").AllowAnonymous(); | ||
|
||
app.Run(); |
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 Microsoft.Extensions.DependencyInjection; | ||
using TramsDataApi.DatabaseModels; | ||
|
||
namespace TramsDataApi.Setup; | ||
|
||
public static class HealthCheckSetup | ||
{ | ||
public static void AddHealthChecks(IServiceCollection services) { | ||
services.AddHealthChecks(); | ||
AddDbHealthChecks(services); | ||
} | ||
|
||
public static void AddDbHealthChecks(IServiceCollection services) { | ||
services.AddHealthChecks() | ||
.AddDbContextCheck<TramsDbContext>("Academies Database"); | ||
} | ||
} |
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