Exemple #1
0
        public (BusHealthStatus, string, IReadOnlyDictionary <string, EndpointHealthResult>) CheckHealth()
        {
            var results = _endpoints.Select(x => new
            {
                InputAddress = x.Key,
                Result       = x.Value.ReceiveEndpoint?.CheckHealth() ?? EndpointHealthResult.Unhealthy(null, "not ready", null)
            }).ToArray();

            var unhealthy = results.Where(x => x.Result.Status == BusHealthStatus.Unhealthy).ToArray();
            var degraded  = results.Where(x => x.Result.Status == BusHealthStatus.Degraded).ToArray();

            var unhappy = unhealthy.Union(degraded).ToArray();

            var names = unhappy.Select(x => x.InputAddress.GetLastPart()).ToArray();

            Dictionary <string, EndpointHealthResult> data = results.ToDictionary(x => x.InputAddress.ToString(), x => x.Result);

            if (unhealthy.Any() || unhappy.Length == results.Length)
            {
                return(BusHealthStatus.Unhealthy, $"Unhealthy Endpoints: {string.Join(",", names)}", data);
            }

            if (degraded.Any())
            {
                return(BusHealthStatus.Degraded, $"Degraded Endpoints: {string.Join(",", names)}", data);
            }

            return(BusHealthStatus.Healthy, "Endpoints are healthy", data);
        }
Exemple #2
0
 UnHealthEndpointHealth()
 {
     _result = EndpointHealthResult.Unhealthy(null, "not ready", null);
 }
 ConnectingEndpointHealth()
 {
     _result = EndpointHealthResult.Healthy(null, "starting");
 }