-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: now using keyed services (#167)
* Feat: now using keyed services * chore: ran cleanup on new code --------- Co-authored-by: Tom Whittington <[email protected]>
- Loading branch information
1 parent
678cc91
commit 0423354
Showing
12 changed files
with
172 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 11 additions & 6 deletions
17
.../Extensions/HttpClientPolicyExtensions.cs → ...xtensions/CsHttpClientPolicyExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
using Polly; | ||
using System.Net; | ||
using Polly; | ||
using Polly.Extensions.Http; | ||
|
||
namespace Dfe.ContentSupport.Web.Extensions; | ||
|
||
public static class HttpClientPolicyExtensions | ||
public static class CsHttpClientPolicyExtensions | ||
{ | ||
public static void AddRetryPolicy(IHttpClientBuilder builder) => | ||
public static void AddRetryPolicy(IHttpClientBuilder builder) | ||
{ | ||
builder | ||
.SetHandlerLifetime(TimeSpan.FromMinutes(5)) | ||
.AddPolicyHandler(GetRetryPolicy()); | ||
} | ||
|
||
public static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy() => | ||
HttpPolicyExtensions.HandleTransientHttpError() | ||
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound) | ||
public static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy() | ||
{ | ||
return HttpPolicyExtensions.HandleTransientHttpError() | ||
.OrResult(msg => msg.StatusCode == HttpStatusCode.NotFound) | ||
.WaitAndRetryAsync(6, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.