private async Task <bool> IsHealthy(ServiceLocation serviceLocation, Channel channel,
                                            TimeSpan workerResponseTimeout)
        {
            Health.HealthClient healthClient = new Health.HealthClient(channel);

            StatusCode healthStatus = await TaskUtils.TimeoutAfter(
                GrpcUtils.IsServingAsync(healthClient, serviceLocation.ServiceName),
                workerResponseTimeout);

            if (healthStatus != StatusCode.OK)
            {
                _logger.LogDebug(
                    "Service location {serviceLocation} is unhealthy and will not be used.",
                    serviceLocation);

                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private async Task <bool> CheckHealthAsync(string serviceName)
        {
            var statusCode = await GrpcUtils.IsServingAsync(_healthClient, serviceName);

            return(statusCode == StatusCode.OK);
        }