-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
118 additions
and
20 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
backend/webapi/Infrastructure/HealthChecks/BackgroundWorkerHealthCheck.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,18 @@ | ||
namespace Pidp.Infrastructure.HealthChecks; | ||
|
||
using Microsoft.Extensions.Diagnostics.HealthChecks; | ||
|
||
public class BackgroundWorkerHealthCheck : IHealthCheck | ||
{ | ||
public bool IsRunning { get; set; } | ||
|
||
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) | ||
{ | ||
if (this.IsRunning) | ||
{ | ||
return Task.FromResult(HealthCheckResult.Healthy("The background service is running.")); | ||
} | ||
|
||
return Task.FromResult(HealthCheckResult.Unhealthy("The background service has stopped.")); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
backend/webapi/Infrastructure/HealthChecks/HealthCheckTag.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,28 @@ | ||
|
||
namespace Pidp.Infrastructure.HealthChecks; | ||
|
||
public class HealthCheckTag | ||
{ | ||
/// <summary> | ||
/// Represents a "backgroundServices" check. | ||
/// </summary> | ||
public static readonly HealthCheckTag BackgroundServices = new("background-services"); | ||
|
||
/// <summary> | ||
/// Represents a "liveness" check. | ||
/// A service that fails a liveness check is considered to be unrecoverable and has to be restarted by the orchestrator. | ||
/// </summary> | ||
public static readonly HealthCheckTag Liveness = new("liveness"); | ||
|
||
/// <summary> | ||
/// Represents a "readiness" check. | ||
/// A service that fails a readiness check is considered to be unable to serve traffic temporarily. | ||
/// </summary> | ||
public static readonly HealthCheckTag Readiness = new("readiness"); | ||
|
||
public string Value { get; } | ||
|
||
private HealthCheckTag(string value) => this.Value = value; | ||
|
||
public static implicit operator string(HealthCheckTag type) => type.Value; | ||
} |
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
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