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

[WIP-DO NOT MERGE] Chaos and Fault Injection polices #553

Closed
wants to merge 3 commits into from

Conversation

reisenberger
Copy link
Member

@reisenberger reisenberger commented Dec 30, 2018

+ per PR 508 to SHA f2bec42
+ plus v7.0.0-compatibility modifications, and other changes, by @reisenberger
/// <returns>The policy instance.</returns>
public static AsyncInjectBehaviourPolicy InjectBehaviourAsync(
Func<Task> behaviour,
Double injectionRate,
Copy link

Choose a reason for hiding this comment

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

should we have a check for < 0 value? across the code base

Copy link
Member Author

Choose a reason for hiding this comment

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

should we have a check for < 0 value? across the code base

Yes, this would be good. I saw the opportunity to add some quick boundary checks in the execution-phase in my contribution, these target the cases where the dynamic Func<..., double> variants generate some out-of-range double as well. But for cases where the injection rate is configured as a non-dynamic Double injectionRate, configuration-time checking would be an improvement.

Tagging this mentally to be done after we've moved the codebase over to the new repo.

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't know if I misunderstood, but I was taking a look at that, and I think the validation you put on ShouldInject method, cover all scenarios since the syntax classes are ensuring that at the end of the day the injectionRate will be always a lambda.

Task<Exception> FaultLambda(Context _, CancellationToken __) => Task.FromResult<Exception>(fault);
Task<double> InjectionRateLambda(Context _) => Task.FromResult<Double>(injectionRate);

return new AsyncInjectOutcomePolicy<TResult>((Func<Context, CancellationToken, Task<Exception>>)FaultLambda, InjectionRateLambda, enabled);
Copy link

Choose a reason for hiding this comment

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

why explicit recasting here?

Copy link
Member Author

Choose a reason for hiding this comment

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

why explicit recasting here?

Good q. Without it the compiler was giving an ambiguous overload resolution error.

Remove code erroneously left in by mistake
{
if (enabled == null) throw new ArgumentNullException(nameof(enabled));

Action<Context> latencyProvider = _ => { SystemClock.Sleep(latency, CancellationToken.None); };
Copy link
Contributor

Choose a reason for hiding this comment

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

Action latencyProvider = _ => { SystemClock.Sleep(latency, CancellationToken.None); };

This guy is not being used, I can remove it after we've moved the codebase over to the new repo.

/// <returns>The policy instance.</returns>
public static AsyncInjectBehaviourPolicy InjectBehaviourAsync(
Func<Task> behaviour,
Double injectionRate,
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't know if I misunderstood, but I was taking a look at that, and I think the validation you put on ShouldInject method, cover all scenarios since the syntax classes are ensuring that at the end of the day the injectionRate will be always a lambda.

reisenberger added a commit to Polly-Contrib/Simmy that referenced this pull request Jan 20, 2019
Bring Simmy codebase across from App-vNext/Polly#553 (and originally App-vNext/Polly#508).

Represents original contributions by @vany0114 , @mebjas and @reisenberger, which @vany0114 has brought to the Simmy repo from Polly.

Noting that all contributors @vany0114 , @mebjas and @reisenberger had signed the .NET Foundation Contributors License Agreement against the Polly repo.
@reisenberger
Copy link
Member Author

Hi @vany0114 Re:

I was taking a look at that, I think the validation you put on ShouldInject method, cover all scenarios since the syntax classes are ensuring that at the end of the day the injectionRate will be always a lambda

That is correct. It would be a small improvement for parameter validation to throw at configuration time rather than execution time for the constant cases, but not essential. Noted on the Simmy repo: Polly-Contrib/Simmy#15

@reisenberger
Copy link
Member Author

Locking this thread (in preference to closing it right now, which reduces visibility), because this no longer represents the latest version of the codebase for this feature. Interested parties should head on over to the Simmy repo where this functionality is being finalised!

@App-vNext App-vNext locked and limited conversation to collaborators Jan 20, 2019
@reisenberger
Copy link
Member Author

Closing as this codebase now exists definitively in the Simmy repo, the readme now links out to Simmy and #499 still tracks on the issues page.

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

Successfully merging this pull request may close these issues.

3 participants