Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1956 +/- ##
=======================================
Coverage 85.91% 85.91%
=======================================
Files 312 312
Lines 6654 6654
Branches 1057 1057
=======================================
Hits 5717 5717
Misses 540 540
Partials 397 397
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
samples/Chaos/Program.cs
Outdated
| var builder = WebApplication.CreateBuilder(args); | ||
| var services = builder.Services; | ||
| services.TryAddSingleton<IChaosManager, ChaosManager>(); | ||
| services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>(); |
There was a problem hiding this comment.
Could just use the AddHttpContextAccessor() method?
samples/Chaos/README.md
Outdated
| # Chaos Example | ||
|
|
||
| This example demonstrates how to use new [chaos engineering](https://www.pollydocs.org/chaos) tools in Polly to inject chaos into HTTP client communication. | ||
| The HTTP client communicates with `https://jsonplaceholder.typicode.com/todos` endpoint. |
There was a problem hiding this comment.
| The HTTP client communicates with `https://jsonplaceholder.typicode.com/todos` endpoint. | |
| The HTTP client communicates with the `https://jsonplaceholder.typicode.com/todos` endpoint. |
samples/Chaos/README.md
Outdated
|
|
||
| To test the application: | ||
|
|
||
| - Run the app using `dotnet run` command. |
There was a problem hiding this comment.
| - Run the app using `dotnet run` command. | |
| - Run the app using the `dotnet run` command. |
samples/Chaos/TodosClient.cs
Outdated
| public async Task<IEnumerable<TodoModel>?> GetTodosAsync(CancellationToken cancellationToken) | ||
| { | ||
| using var request = new HttpRequestMessage(HttpMethod.Get, "/todos"); | ||
| using var response = await client.SendAsync(request, cancellationToken); |
There was a problem hiding this comment.
Could simplify this down to just use GetFromJsonAsync<T>()?
There was a problem hiding this comment.
I wanted to include handling of invalid status codes which is not possible with that method.
There was a problem hiding this comment.
I thought that method implicitly called EnsureStatusCode() for you, so it's basically the same? I meant the one that's an overload of HttpClient.
There was a problem hiding this comment.
Based on my understanding it does not do status code checking. (it would prevent deserializing error bodies for example).
There was a problem hiding this comment.
Oh, if that's the case I've been using it wrong a lot then. I assumed it checked the status code, as otherwise you'd get a weird result if you tried to deserialise the response as a model for an OK and instead the body was an ErrorDetails or an HTML error page or something.
There was a problem hiding this comment.
Also it would be weird to do a get knowing in advance you were just going to get an error details because it would fail. Not checking the status would make more sense if it was a discriminated union.
There was a problem hiding this comment.
You are right, it checks the status code as well. Simplified.
Pull Request
The issue or feature being addressed
Contributes to #1954
Details on the issue fix or feature implementation
An example of how to use chaos strategies alongside the resilience. This sample will be referenced in the upcoming blog post about chaos engineering with Polly.
Confirm the following