feat: complete TASK-WP0-07 supervisor

This commit is contained in:
suyx
2026-07-27 23:28:36 +08:00
parent 2dd6f5c2c2
commit 096a1f1279
22 changed files with 1717 additions and 6 deletions
+35
View File
@@ -0,0 +1,35 @@
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) => new(checkCode, DiagnosticResult.Pass, messageKey, DateTimeOffset.UtcNow);
internal static DiagnosticCheck Warning(string checkCode, string messageKey) => new(checkCode, DiagnosticResult.Warning, messageKey, DateTimeOffset.UtcNow);
internal static DiagnosticCheck Fail(string checkCode, string messageKey) => new(checkCode, DiagnosticResult.Fail, messageKey, 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);
}