예제 #1
0
        public ServiceStatus ProvideFor(Service service)
        {
            if (service == null)
            {
                throw new ArgumentNullException();
            }

            var canaryEndpoint = new Uri(service.Location, "/service/healthcheck/asg");

            try
            {
                var response = _httpClient
                               .GetAsync(canaryEndpoint)
                               .GetAwaiter()
                               .GetResult();

                if (response.IsSuccessStatusCode)
                {
                    return(ServiceStatus.HealthyFrom(service));
                }

                return(ServiceStatus.UnhealthyFrom(service));
            }
            catch (Exception)
            {
                return(ServiceStatus.UnhealthyFrom(service));
            }
        }