[Http.Resilience] Timeout can't filter based on request?
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 894
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 23
Description
It seems that `Microsoft.Extensions.Http.Resilience` replaces the older `Microsoft.Extensions.Http.Polly` extensions.
One thing I noticed is that the newer package lost the functionality to filter whether to apply timeouts or not based on the `HttpRequestMessage` object.
In the `Microsoft.Extensions.Http.Polly` package, I could do:
```cs
services
.AddHttpClient()
.AddPolicyHandler((serviceProvider, request) =>
request.RequestUri?.AbsolutePath.Contains("something", StringComparison.OrdinalIgnoreCase) is true
? Policy.TimeoutAsync(timeSpan)
: Policy.NoOpAsync());
```
I don't see such option with the new APIs (which seem to directly use the Polly API). Some strategies, like Retry, do allow to access the `HttpRequestMessage` object, in the `RetryStrategyOptions`'s `ShouldHandle`. The `TimeoutStrategyOptions` doesn't seem to have any configuration like that.
Am I missing something and there is some way to filter timeout strategy based on the request message, or is this functionality just not there? Will it be added?
Contributor guide
Research direction
Start by comparing the Microsoft.Extensions.Http.Polly AddPolicyHandler request predicate with the newer Microsoft.Extensions.Http.Resilience TimeoutStrategyOptions. Read the existing RetryStrategyOptions.ShouldHandle request access and related resilience tests or entry points; done means the timeout strategy can be conditionally applied per HttpRequestMessage, with coverage for both filtered and unfiltered requests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design, networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100