示例#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));
        }