コード例 #1
0
        public ResultWrapper <NodeStatusResult> health_nodeStatus()
        {
            CheckHealthResult checkHealthResult = _nodeHealthService.CheckHealth();

            string[]         messages = checkHealthResult.Messages.Select(x => x.Message).ToArray();
            NodeStatusResult result   = new() { Healthy = checkHealthResult.Healthy, Messages = messages };

            return(ResultWrapper <NodeStatusResult> .Success(result));
        }
    }
コード例 #2
0
        public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
        {
            try
            {
                CheckHealthResult healthResult = await Task.Run(() => _nodeHealthService.CheckHealth(), cancellationToken);

                string description = FormatMessages(healthResult.Messages.Select(x => x.LongMessage));
                if (healthResult.Healthy)
                {
                    return(HealthCheckResult.Healthy(description));
                }

                return(HealthCheckResult.Unhealthy(description));
            }
            catch (Exception ex)
            {
                return(new HealthCheckResult(context.Registration.FailureStatus, exception: ex));
            }
        }
コード例 #3
0
        public Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
        {
            try
            {
                CheckHealthResult healthResult = _nodeHealthService.CheckHealth();
                if (_logger.IsTrace)
                {
                    _logger.Trace($"Checked health result. Healthy: {healthResult.Healthy}");
                }
                string description = FormatMessages(healthResult.Messages.Select(x => x.LongMessage));
                if (healthResult.Healthy)
                {
                    return(Task.FromResult(HealthCheckResult.Healthy(description)));
                }

                return(Task.FromResult(HealthCheckResult.Unhealthy(description)));
            }
            catch (Exception ex)
            {
                return(Task.FromResult(new HealthCheckResult(context.Registration.FailureStatus, exception: ex)));
            }
        }