creates simple healthchecks
This commit is contained in:
11
Abstracts/HealthCheck.cs
Normal file
11
Abstracts/HealthCheck.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace MCVIngenieros.Healthchecks.Abstracts;
|
||||
|
||||
public abstract class HealthCheck : IHealthCheck
|
||||
{
|
||||
public virtual int? RetryAttempts => 2;
|
||||
public virtual TimeSpan? Timeout => TimeSpan.FromSeconds(3);
|
||||
public virtual TimeSpan? RetryDelay => TimeSpan.FromSeconds(1);
|
||||
public virtual HealthCheckSeverity? Severity => HealthCheckSeverity.Critical;
|
||||
public virtual string? Description => null;
|
||||
public abstract Task<HealthCheckResult> CheckAsync(CancellationToken cancellationToken = default);
|
||||
}
|
5
Abstracts/HealthCheckSeverity.cs
Normal file
5
Abstracts/HealthCheckSeverity.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace MCVIngenieros.Healthchecks.Abstracts;
|
||||
|
||||
// Severity levels for health checks
|
||||
public enum HealthCheckSeverity { Info, Warning, Critical }
|
||||
|
16
Abstracts/IHealthCheck.cs
Normal file
16
Abstracts/IHealthCheck.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace MCVIngenieros.Healthchecks.Abstracts;
|
||||
|
||||
// Health check interface
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public interface IHealthCheck
|
||||
{
|
||||
int? RetryAttempts { get; }
|
||||
TimeSpan? Timeout { get; }
|
||||
TimeSpan? RetryDelay { get; }
|
||||
HealthCheckSeverity? Severity { get; }
|
||||
string? Description { get; }
|
||||
|
||||
Task<HealthCheckResult> CheckAsync(CancellationToken cancellationToken = default);
|
||||
}
|
17
Abstracts/IHealthCheckContainer.cs
Normal file
17
Abstracts/IHealthCheckContainer.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace MCVIngenieros.Healthchecks.Abstracts;
|
||||
|
||||
// Health check container interface
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public interface IHealthCheckContainer
|
||||
{
|
||||
Task<List<HealthCheckResult>> RunAllChecks(CancellationToken cancellationToken = default);
|
||||
Task<HealthCheckResult?> RunCheck(string name, CancellationToken cancellationToken = default);
|
||||
Task<List<HealthCheckResult>> RunChecks(IEnumerable<string> names, CancellationToken cancellationToken = default);
|
||||
IReadOnlyList<string> GetAllCheckNames();
|
||||
void DiscoverHealthChecks();
|
||||
IReadOnlyDictionary<string, IHealthCheck> GetAllChecks();
|
||||
Task<List<HealthCheckResult>> GetAllChecksResults(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
8
Abstracts/IHealthCheckWithOptions.cs
Normal file
8
Abstracts/IHealthCheckWithOptions.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using MCVIngenieros.Healthchecks.Options;
|
||||
|
||||
namespace MCVIngenieros.Healthchecks.Abstracts;
|
||||
|
||||
public interface IHealthCheckWithOptions : IHealthCheck
|
||||
{
|
||||
HealthChecksConfigs Options { get; }
|
||||
}
|
Reference in New Issue
Block a user