refactor: 重构 Gitee 健康检查
This commit is contained in:
parent
edac104fbc
commit
03ceefcd11
|
@ -42,10 +42,17 @@ namespace Bootstrap.Admin.HealthChecks
|
||||||
{
|
{
|
||||||
var sw = Stopwatch.StartNew();
|
var sw = Stopwatch.StartNew();
|
||||||
Exception? error = null;
|
Exception? error = null;
|
||||||
var result = await _client.HttpClient.GetFromJsonAsync<object>($"/api/Gitee/{url}", cancellationToken);
|
object? result = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = await _client.HttpClient.GetFromJsonAsync<object>($"/api/Gitee/{url}", cancellationToken);
|
||||||
|
}
|
||||||
|
catch (Exception ex) { error = ex; }
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
data.Add(url, error == null ? $"{result} Elapsed: {sw.Elapsed}" : $"{result} Elapsed: {sw.Elapsed} Exception: {error}");
|
data.Add(url, error == null
|
||||||
})).ToArray());
|
? $"{result} Elapsed: {sw.Elapsed}"
|
||||||
|
: $"Elapsed: {sw.Elapsed} Exception: {error}");
|
||||||
|
})).ToArray(), cancellationToken);
|
||||||
return Task.FromResult(HealthCheckResult.Healthy("Ok", data));
|
return Task.FromResult(HealthCheckResult.Healthy("Ok", data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue