Exemplo n.º 1
0
        public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = new CancellationToken())
        {
            var timer  = Stopwatch.StartNew();
            var result = await _client.GetResponseCode(new GetPingRequest());

            timer.Stop();
            var durationString = timer.Elapsed.ToHumanReadableString();

            if (result != HttpStatusCode.OK)
            {
                return(HealthCheckResult.Unhealthy(HealthCheckResultDescription, null,
                                                   new Dictionary <string, object> {
                    { "Duration", durationString }
                }));
            }

            return(HealthCheckResult.Healthy(HealthCheckResultDescription,
                                             new Dictionary <string, object> {
                { "Duration", durationString }
            }));
        }
 public Task <HttpStatusCode> GetResponseCode(IGetApiRequest request)
 {
     return(_apiClient.GetResponseCode(request));
 }