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

Simmy v8 #1459

Merged
merged 55 commits into from
Sep 19, 2023
Merged

Simmy v8 #1459

merged 55 commits into from
Sep 19, 2023

Conversation

vany0114
Copy link
Contributor

@vany0114 vany0114 commented Aug 7, 2023

Migrates Simmy to use the new Polly v8

This PR migrates all the Simmy functionality into the new Polly v8 version so that Simmy can also take advantage of all the improvements made in the v8 version.

Details on the issue fix or feature implementation

  • Simmy now lives in the same Polly package so that resilience and chaos features are shipped together.
    • Pros:
      • Easier releases
      • Easier to maintain
      • All the Polly internal stuff is available for Simmy too
      • Any bug fix or improvement is immediately available in Simmy, which allows us to keep Simmy up to date in regards to Polly.
      • Consumers don't need to worry about adding another dependency when it comes to handling chaos.
    • Cons:
      • We cannot track Simmy usage statistics, like downloads, repos where it is being used, etc, since now it will be bundled in the same package as Polly.
  • I dropped the Inject prefix from the name, e.g: InjectBehaviorPolicy -> BehaviorChaosStrategy
  • I used the ChaosStrategy suffix rather than ResilienceStrategy to make it clearer
  • The new strategies are:
    • BehaviorChaosStrategy
    • LatencyChaosStrategy
    • OutcomeChaosStrategy: this one provides two functionalities, inject faults as well as custom results.
  • All of the chaos strategies inherit from the MonkeyStrategy implementation, which is also exposed so that people can extend it to create their own chaos strategies.

TODO:

  • Docs
  • Examples

Questions:

  • Do you guys think would be better to create an AddChaosStrategy service collection extension to separate it from AddResilienceStrategy so that is clearer for the consumers and also to allow keeping them separate in different registries, etc? If so I guess this would require some extra effort to potentially use a CompositeChaosStrategyBuilder and/or generic constraints.

Confirm the following

  • I started this PR by branching from the head of the default branch
  • I have targeted the PR to merge into the default branch
  • I have included unit tests for the issue/feature
  • I have successfully run a local build

…strategies will inherit from

* add LatencyChaosStrategy

Note: this is still work in progress, I'm just getting familiar with the v8 implemenation.
…rate and enabled options

* refactor MonkeyStrategy so that it is instantiated out of options object rather than individual parameters
* expose ShouldInject method in the MonkeyStrategy so that consumers who extend/inherit it can also use it for convenience
* add Latency property to the LatencyStrategyOptions as a primitive value to not force consumers to always pass a generator
* refactors the LatencyChaosStrategy so that the code it's wrap inside a try/catch to handle canceled operations, since the execution can be also canceled within the ShouldInject method or even within the ExecuteCallbackSafeAsync
…s the logic to handle a callback of type T vs TResult to make it easier and clear to consumers, and avoid confusion so that they don't have to worry about it.
# Conflicts:
#	src/Polly.Core/Utils/OutcomeResilienceStrategy.cs
@martintmk martintmk mentioned this pull request Sep 8, 2023
4 tasks
@vany0114
Copy link
Contributor Author

@martintmk 100% of code coverage! I think we can merge this guy now and I'll continue working on any other feedback, docs, examples etc, in another PR, so that @clpun and @joperezr can continue working on the dotnet extensions release.

image

@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.63% 🎉

Comparison is base (1bdaf86) 83.99% compared to head (7d98bab) 84.63%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1459      +/-   ##
==========================================
+ Coverage   83.99%   84.63%   +0.63%     
==========================================
  Files         280      306      +26     
  Lines        6548     6820     +272     
  Branches     1020     1044      +24     
==========================================
+ Hits         5500     5772     +272     
  Misses        839      839              
  Partials      209      209              
Flag Coverage Δ
linux ?
macos 84.63% <100.00%> (+0.63%) ⬆️
windows 84.63% <100.00%> (+0.63%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
src/Polly.Core/Utils/TimeProviderExtensions.cs 100.00% <ø> (ø)
...lly.Core/Simmy/Behavior/BehaviorActionArguments.cs 100.00% <100.00%> (ø)
...Polly.Core/Simmy/Behavior/BehaviorChaosStrategy.cs 100.00% <100.00%> (ø)
...immy/Behavior/BehaviorPipelineBuilderExtensions.cs 100.00% <100.00%> (ø)
...lly.Core/Simmy/Behavior/BehaviorStrategyOptions.cs 100.00% <100.00%> (ø)
...Core/Simmy/Behavior/OnBehaviorInjectedArguments.cs 100.00% <100.00%> (ø)
src/Polly.Core/Simmy/EnabledGeneratorArguments.cs 100.00% <100.00%> (ø)
...olly.Core/Simmy/InjectionRateGeneratorArguments.cs 100.00% <100.00%> (ø)
...c/Polly.Core/Simmy/Latency/LatencyChaosStrategy.cs 100.00% <100.00%> (ø)
src/Polly.Core/Simmy/Latency/LatencyConstants.cs 100.00% <100.00%> (ø)
... and 17 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@martintmk
Copy link
Contributor

@martintmk 100% of code coverage! I think we can merge this guy now and I'll continue working on any other feedback, docs, examples etc, in another PR, so that @clpun and @joperezr can continue working on the dotnet extensions release.

image

I agree we can merge and based on how the API review goes hide new APIs upon release. Btw, there are still issues with tests as 4 mutants survived with your changes. You need to add additional tests to kill them:

image

You can find mutation report here:

image

@martintmk martintmk enabled auto-merge (squash) September 19, 2023 14:54
@martintmk martintmk merged commit 7cc2ea1 into App-vNext:main Sep 19, 2023
14 checks passed
@joperezr
Copy link

This is awesome, special thanks to @vany0114 and @martintmk for all your hard work here!

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.

5 participants