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

[Proposal] Introduce ResilienceStrategyBuilderBase #1236

Merged
merged 4 commits into from
May 30, 2023

Conversation

martintmk
Copy link
Contributor

@martintmk martintmk commented May 30, 2023

Details on the issue fix or feature implementation

One thing I wasn't a big fan of was the duplications of extensions for non-reactive strategies such as Timeout or RateLimiter.

In this PR I am introducing ResilienceStrategyBuilderBase class. The extensibility author can use is to target extensions that work for both generic and non-generic strategies.

This way full set of extensions are always exposed for both generic and non-generic builders and there are no duplications.

The extension bellow will be visible for both builder types:

public static TBuilder AddTimeout<TBuilder>(this TBuilder builder, TimeoutStrategyOptions options)
    where TBuilder : ResilienceStrategyBuilderBase
{
    builder.AddStrategy(context => new TimeoutResilienceStrategy(options, context.TimeProvider, context.Telemetry), options);
    return builder;
}

I have dropped a bunch of duplicate extensions.

What do you think about this idea?

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 May 30, 2023
@martintmk martintmk added this to the v8.0.0 milestone May 30, 2023
@martincostello
Copy link
Member

This seems reasonable to me.

@martintmk martintmk force-pushed the mtomka/resiliencestratebybuilderbase branch from e6dcdfb to 24834e5 Compare May 30, 2023 11:12
@codecov
Copy link

codecov bot commented May 30, 2023

Codecov Report

Merging #1236 (e69d105) into main (141bd0a) will decrease coverage by 0.11%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1236      +/-   ##
==========================================
- Coverage   82.91%   82.81%   -0.11%     
==========================================
  Files         262      263       +1     
  Lines        6141     6103      -38     
  Branches      966      966              
==========================================
- Hits         5092     5054      -38     
  Misses        844      844              
  Partials      205      205              
Flag Coverage Δ
linux 82.81% <100.00%> (-0.11%) ⬇️
macos 82.81% <100.00%> (-0.11%) ⬇️
windows ?

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

Impacted Files Coverage Δ
...ry/TelemetryResilienceStrategyBuilderExtensions.cs 100.00% <ø> (ø)
...rcuitBreakerResilienceStrategyBuilderExtensions.cs 100.00% <100.00%> (ø)
...rc/Polly.Core/ResilienceStrategyBuilder.TResult.cs 100.00% <100.00%> (ø)
src/Polly.Core/ResilienceStrategyBuilder.cs 100.00% <100.00%> (ø)
.../Retry/RetryResilienceStrategyBuilderExtensions.cs 100.00% <100.00%> (ø)
...lly.Core/Strategy/ResilienceStrategyBuilderBase.cs 100.00% <100.00%> (ø)
...eout/TimeoutResilienceStrategyBuilderExtensions.cs 100.00% <100.00%> (ø)
.../RateLimiterResilienceStrategyBuilderExtensions.cs 100.00% <100.00%> (ø)

@martintmk martintmk marked this pull request as ready for review May 30, 2023 12:36
@martintmk martintmk requested a review from martincostello May 30, 2023 12:45
@martintmk martintmk merged commit 045cec0 into main May 30, 2023
@martintmk martintmk deleted the mtomka/resiliencestratebybuilderbase branch May 30, 2023 13:16
@martintmk martintmk mentioned this pull request May 30, 2023
4 tasks
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