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

Introduce OutcomeResilienceStrategy and drop some internals #1330

Merged
merged 4 commits into from
Jun 20, 2023

Conversation

martintmk
Copy link
Contributor

@martintmk martintmk commented Jun 20, 2023

Details on the issue fix or feature implementation

For both non-generic and generic strategies we use the same implementation. Ever bult-in strategy that handles the outcomes uses the same concepts.

  • Generic ones are only handling a single T result
  • Non-generic ones are handling the results as object

To unify both of these and not split implementations we have used the Invokers that wrap the delegates into usable form for these strategies.

I was thinking on how we can simplify this handling even more and came with generic OutcomeResilienceStrategy<T>. When deriving from this strategy, you can use delegates directly without any additional layers.

So for example:

  • RetryResilienceStrategy<T> - handles only results of type T
  • RetryResilienceStrategy<object> - handles all result types (non-generic strategy)

This also allows us to drop all internal invokers. So far, OutcomeResilienceStrategy<T> is kept internal, but we can make it public later.

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

@martintmk martintmk added the v8 Issues related to the new version 8 of the Polly library. label Jun 20, 2023
@martintmk martintmk added this to the v8.0.0 milestone Jun 20, 2023
src/Polly.Core/Outcome.cs Show resolved Hide resolved
src/Polly.Core/Polly.Core.csproj Outdated Show resolved Hide resolved
src/Polly.Core/Utils/OutcomeResilienceStrategy.cs Outdated Show resolved Hide resolved
src/Polly.Core/Utils/OutcomeResilienceStrategy.cs Outdated Show resolved Hide resolved
@martintmk martintmk force-pushed the mtomka/introduce-outcomeresiliencestrategy branch from 36f47bc to 3e58672 Compare June 20, 2023 08:33
@martintmk martintmk enabled auto-merge (squash) June 20, 2023 09:24
@codecov
Copy link

codecov bot commented Jun 20, 2023

Codecov Report

Merging #1330 (3d7838c) into main (47aef87) will decrease coverage by 0.13%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1330      +/-   ##
==========================================
- Coverage   83.66%   83.54%   -0.13%     
==========================================
  Files         270      268       -2     
  Lines        6448     6400      -48     
  Branches     1010     1003       -7     
==========================================
- Hits         5395     5347      -48     
  Misses        844      844              
  Partials      209      209              
Flag Coverage Δ
linux 83.54% <100.00%> (-0.13%) ⬇️
macos ?
windows 83.54% <100.00%> (-0.13%) ⬇️

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

Impacted Files Coverage Δ
.../Polly.Core/CircuitBreaker/Health/HealthMetrics.cs 100.00% <ø> (ø)
src/Polly.Core/OutcomeArguments.cs 100.00% <ø> (ø)
src/Polly.Core/ResilienceStrategyBuilderContext.cs 100.00% <ø> (ø)
...CircuitBreaker/CircuitBreakerResilienceStrategy.cs 100.00% <100.00%> (ø)
...rcuitBreakerResilienceStrategyBuilderExtensions.cs 100.00% <100.00%> (ø)
...ircuitBreaker/Controller/CircuitStateController.cs 100.00% <100.00%> (ø)
src/Polly.Core/Fallback/FallbackHandler.cs 100.00% <100.00%> (ø)
.../Polly.Core/Fallback/FallbackResilienceStrategy.cs 100.00% <100.00%> (ø)
...ack/FallbackResilienceStrategyBuilderExtensions.cs 100.00% <100.00%> (ø)
...Core/Hedging/Controller/HedgingExecutionContext.cs 100.00% <100.00%> (ø)
... and 8 more

@martintmk martintmk merged commit af39ebe into main Jun 20, 2023
9 of 10 checks passed
@martintmk martintmk deleted the mtomka/introduce-outcomeresiliencestrategy branch June 20, 2023 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 Issues related to the new version 8 of the Polly library.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants