I'm trying make httpclient requests through a helper function that will manage a circuitbreaker polly policy.
I'm trying to call it like so
var response = clientFactory.MakeRequest(() => client.GetAsync("/"));
Inside of the client factory I have my circuit breaker policy defined and I'm trying to execute the lambda above using that policy like so
public async Task<HttpResponseMessage> MakeRequest(Func<HttpResponseMessage> request)
{
var response = policy.ExecuteAsync(() => request.Invoke());
return response;
}
I'm fairly new to Lambda's as a whole and passing it as a function gets more confusing. How do I configure the function and the first line of code to execute the client and return the HttpResponseMessage? I don't think Task<HttpResponseMessage> or Func<HttpResponseMessage> is correct