Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Chaos Engineering to inject random crashes into calls #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fernandobianchini
Copy link

No description provided.

Copy link
Owner

@natenho natenho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @fernandobianchini, I've added some comments to the PR for your consideration.

Thank you for your contribution!!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of the "IChaosStrategy" name? It sounds better to me.


var bodyBytes = Encoding.UTF8.GetBytes($"Error {httpResponse.StatusCode}: {HttpStatusCode.ServiceUnavailable}");

await httpResponse.Body.WriteAsync(bodyBytes, 0, bodyBytes.Length, default);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The await is not necessary here, you can directly return the task


var bodyBytes = Encoding.UTF8.GetBytes($"Error {httpResponse.StatusCode}: {HttpStatusCode.InternalServerError}");

await httpResponse.Body.WriteAsync(bodyBytes, 0, bodyBytes.Length, default);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The await is not necessary here, you can directly return the task

{
var responseDelay = new Random().Next(_options.Value.MinimumLatencyTime, _options.Value.MaximumLatencyTime);
_logger.LogInformation($"Chaos Latency (ms): {responseDelay}");
await Task.Delay(responseDelay);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The await is not necessary here, you can directly return the task


var bodyBytes = Encoding.UTF8.GetBytes($"Error {httpResponse.StatusCode}: {HttpStatusCode.BadRequest}");

await httpResponse.Body.WriteAsync(bodyBytes, 0, bodyBytes.Length, default);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The await is not necessary here, you can directly return the task


}

await _next(httpContext);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The await is not necessary here, you can directly return the task :)


public async Task Invoke(HttpContext httpContext)
{
if (_options.Value.Enabled)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inverting this if would reduce the nesting

"profiles": {
"Mockaco": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "hello/fernando",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this specific launch settings

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants