The order in which Polly policies are encapsulated change the final result. Which is the best order if I want to use the following policies? This is the best order I could think of: the retries should be submitted to the bulkhead limits, and the circuit breaking is a lower-level policy that follows the timeout policy. Makes sense?
services.AddHttpClient<IService, Service>()
.AddPolicyHandler(PolicyConfig.RetryPolicy);
.AddPolicyHandler(PolicyConfig.BulkheadPolicy)
.AddPolicyHandler(PolicyConfig.CircuitBreakingPolicy)
.AddPolicyHandler(PolicyConfig.TimeoutPolicy)
The policies are applied in the order defined, i.e. the first policy is the outer one, all the way to the last one (the innermost one).
Relevant documentation:
https://github.com/App-vNext/Polly/wiki/Polly-and-HttpClientFactory#what-order-are-multiple-policies-applied-in