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 OutcomeArguments #1245

Merged
merged 2 commits into from
Jun 5, 2023

Conversation

martintmk
Copy link
Contributor

@martintmk martintmk commented Jun 1, 2023

Details on the issue fix or feature implementation

Came up in the API review.

These could simplify the delegate definition from:

new ResilienceStrategyBuilder<HttpResponseMessage>()
    .AddRetry(new RetryStrategyOptions<HttpResponseMessage>
    {
        ShouldRetry = (outcome, args)  => outcome switch
        {
            { Exception: HttpRequestException } => PredicateResult.True,
            { Result: HttpResponseMessage response } when !response.IsSuccessStatusCode => PredicateResult.True,
            _ => PredicateResult.False
        }
    });

To:

new ResilienceStrategyBuilder<HttpResponseMessage>()
    .AddRetry(new RetryStrategyOptions<HttpResponseMessage>
    {
        ShouldRetry = outcome => outcome switch
        {
            { Exception: HttpRequestException } => PredicateResult.True,
            { Result: HttpResponseMessage response } when !response.IsSuccessStatusCode => PredicateResult.True,
            _ => PredicateResult.False
        }
    });

Slightly simpler syntax at expense of one extra type. Would still allow us to pass the individual arguments to telemetry. The IResilienceArguments interface won't have much use anymore.

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 1, 2023
@martintmk martintmk added this to the v8.0.0 milestone Jun 1, 2023
@martintmk
Copy link
Contributor Author

@martincostello , @joelhulen what's your opinion here? Should I give this a shot?

Copy link
Member

@martincostello martincostello left a comment

Choose a reason for hiding this comment

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

Seems OK to me.

src/Polly.Core/Strategy/OutcomeArguments.cs Outdated Show resolved Hide resolved
@martintmk martintmk force-pushed the mtomka/introduce-outcomearguments branch 3 times, most recently from 5ccf295 to 78c2346 Compare June 5, 2023 09:09
@codecov
Copy link

codecov bot commented Jun 5, 2023

Codecov Report

Merging #1245 (30381b9) into main (2201aaf) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1245      +/-   ##
==========================================
+ Coverage   82.81%   82.85%   +0.04%     
==========================================
  Files         265      261       -4     
  Lines        6105     6120      +15     
  Branches      967      967              
==========================================
+ Hits         5056     5071      +15     
  Misses        844      844              
  Partials      205      205              
Flag Coverage Δ
linux ?
macos 82.85% <100.00%> (+0.04%) ⬆️
windows ?

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

Impacted Files Coverage Δ
...ack/FallbackResilienceStrategyBuilderExtensions.cs 100.00% <ø> (ø)
....Core/Strategy/ResilienceStrategyBuilderContext.cs 100.00% <ø> (ø)
...rc/Polly.Core/Timeout/TimeoutResilienceStrategy.cs 100.00% <ø> (ø)
src/Polly.Extensions/Telemetry/EnrichmentUtil.cs 100.00% <ø> (ø)
...CircuitBreaker/CircuitBreakerResilienceStrategy.cs 100.00% <100.00%> (ø)
...re/CircuitBreaker/CircuitBreakerStrategyOptions.cs 100.00% <100.00%> (ø)
...ircuitBreaker/Controller/CircuitStateController.cs 100.00% <100.00%> (ø)
...ly.Core/CircuitBreaker/OnCircuitClosedArguments.cs 100.00% <100.00%> (ø)
...ly.Core/CircuitBreaker/OnCircuitOpenedArguments.cs 100.00% <100.00%> (ø)
src/Polly.Core/Fallback/FallbackHandler.Handler.cs 100.00% <100.00%> (ø)
... and 36 more

@martintmk martintmk marked this pull request as ready for review June 5, 2023 09:27
@martintmk martintmk requested a review from martincostello June 5, 2023 09:27
@martintmk martintmk force-pushed the mtomka/introduce-outcomearguments branch from 78c2346 to 88d8612 Compare June 5, 2023 09:34
@martintmk martintmk enabled auto-merge (squash) June 5, 2023 10:05
@martintmk martintmk merged commit 034177c into main Jun 5, 2023
@martintmk martintmk deleted the mtomka/introduce-outcomearguments branch June 5, 2023 10:36
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