You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update httpclient-guidelines.md
Added example of using a Polly policy with a static HttpClient instance.
* Update docs/fundamentals/networking/http/httpclient-guidelines.md
Co-authored-by: David Pine <[email protected]>
* Update docs/fundamentals/networking/http/httpclient-guidelines.md
Co-authored-by: David Pine <[email protected]>
* Apply suggestions from code review
---------
Co-authored-by: David Pine <[email protected]>
Copy file name to clipboardExpand all lines: docs/fundamentals/networking/http/httpclient-guidelines.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,38 @@ To summarize recommended `HttpClient` use in terms of lifetime management, you s
52
52
53
53
For more information about managing `HttpClient` lifetime with `IHttpClientFactory`, see [`IHttpClientFactory` guidelines](../../../core/extensions/httpclient-factory.md#httpclient-lifetime-management).
54
54
55
+
## Resilience policies with static clients
56
+
57
+
It's possible to configure a `static` or *singleton* client to use any number of resilience policies using the following pattern:
- Relies on [Microsoft.Extensions.Http.Polly](https://www.nuget.org/packages/Microsoft.Extensions.Http.Polly) NuGet package, transitively the [Polly.Extensions.Http](https://www.nuget.org/packages/Polly.Extensions.Http) NuGet package for the `HttpPolicyExtensions` type.
82
+
- Specifies a transient HTTP error handler, configured with retry policy that with each attempt will exponentially backoff delay intervals.
83
+
- Defines a pooled connection lifetime of fifteen minutes for the `socketHandler`.
84
+
- Passes the `socketHandler` to the `policyHandler` with the retry logic.
85
+
- Instantiates an `HttpClient` given the `policyHandler`.
0 commit comments