예제 #1
0
        public async Task <ComponentStatus> EvaluateComponentAsync(string component)
        {
            if (_evaluators.TryGetValue(component, out var evaluator))
            {
                return(await evaluator.EvaluateAsync());
            }

            return(ComponentStatus.Down(component));
        }
예제 #2
0
        public async Task <ComponentStatus> EvaluateAsync(string component, HttpRequestMessage request, Func <HttpResponseMessage, Task <bool> > fn)
        {
            var response = await _http.SendAsync(request).ConfigureAwait(false);

            var details = new Dictionary <string, object>
            {
                ["Uri"]        = request.RequestUri,
                ["Method"]     = request.Method,
                ["StatusCode"] = response.StatusCode
            };

            var up = await fn(response);

            return(up
                ? ComponentStatus.Up(component, details)
                : ComponentStatus.Down(component, details));
        }