39 lines
1.7 KiB
C#
39 lines
1.7 KiB
C#
namespace Dada.Supervisor;
|
|
|
|
internal enum DiagnosticResult
|
|
{
|
|
Pass,
|
|
Warning,
|
|
Fail,
|
|
}
|
|
|
|
internal sealed record DiagnosticCheck(string CheckCode, DiagnosticResult Result, string MessageKey, DateTimeOffset CheckedAt)
|
|
{
|
|
internal static DiagnosticCheck Pass(string checkCode, string messageKey) => Create(checkCode, DiagnosticResult.Pass, messageKey);
|
|
internal static DiagnosticCheck Warning(string checkCode, string messageKey) => Create(checkCode, DiagnosticResult.Warning, messageKey);
|
|
internal static DiagnosticCheck Fail(string checkCode, string messageKey) => Create(checkCode, DiagnosticResult.Fail, messageKey);
|
|
|
|
private static DiagnosticCheck Create(string checkCode, DiagnosticResult result, string messageKey) =>
|
|
new(RedactionPolicy.Code(checkCode, "invalid_check"), result, RedactionPolicy.Code(messageKey, "diagnostic_redacted"), DateTimeOffset.UtcNow);
|
|
}
|
|
|
|
internal sealed record DiagnosticStorageSummary(long UsedBytes, long CapacityBytes, long ReclaimableBytes);
|
|
internal sealed record CredentialStatus(string Service, bool Configured);
|
|
|
|
internal sealed record DiagnosticReport(
|
|
string AppVersion,
|
|
SupervisorState SupervisorState,
|
|
string BindHost,
|
|
int FixedPort,
|
|
IReadOnlyList<DiagnosticCheck> Checks,
|
|
DiagnosticStorageSummary Storage,
|
|
IReadOnlyList<CredentialStatus> Credentials)
|
|
{
|
|
internal static DiagnosticReport Create(
|
|
SupervisorState supervisorState,
|
|
IReadOnlyList<DiagnosticCheck> checks,
|
|
DiagnosticStorageSummary storage,
|
|
IReadOnlyList<CredentialStatus> credentials) =>
|
|
new(typeof(DiagnosticReport).Assembly.GetName().Version?.ToString() ?? "0.0.0", supervisorState, LoopbackEndpoint.Host, LoopbackEndpoint.Port, checks, storage, credentials);
|
|
}
|