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 ResilienceStrategyBuilder.Validator #1412

Merged
merged 4 commits into from
Jul 18, 2023
Merged

Conversation

martintmk
Copy link
Contributor

@martintmk martintmk commented Jul 18, 2023

Details on the issue fix or feature implementation

This API addition allows the library to inject their own validator and get rid of the reflection that is used in the default validator.
This allows the library that consumes the Polly to be AOT compatible.

In ideal world we could just use the generators introduced by dotnet/runtime#85475.
However, this would pull the heavy Microsoft.Extensions.Options dependency into the core package.

As a follow-up task after #1360 is merged we can introduce ResilienceValidator.Validate utility API in Polly.Extensions that uses generated validators for validation and doesn't use reflection at all (for all built-in options).

Contributes to #1110

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 Jul 18, 2023
@martintmk martintmk added this to the v8.0.0 milestone Jul 18, 2023
@codecov
Copy link

codecov bot commented Jul 18, 2023

Codecov Report

Merging #1412 (5376066) into main (1acb88a) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1412      +/-   ##
==========================================
+ Coverage   83.78%   83.81%   +0.03%     
==========================================
  Files         273      274       +1     
  Lines        6470     6482      +12     
  Branches     1008     1009       +1     
==========================================
+ Hits         5421     5433      +12     
  Misses        840      840              
  Partials      209      209              
Flag Coverage Δ
linux 83.81% <100.00%> (+0.03%) ⬆️
macos ?
windows ?

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

Impacted Files Coverage Δ
.../Polly.Core/Registry/ResilienceStrategyRegistry.cs 100.00% <100.00%> (ø)
src/Polly.Core/ResilienceStrategyBuilderBase.cs 100.00% <100.00%> (ø)
src/Polly.Core/ResilienceValidationContext.cs 100.00% <100.00%> (ø)
...ry/TelemetryResilienceStrategyBuilderExtensions.cs 100.00% <100.00%> (ø)

@martintmk martintmk enabled auto-merge (squash) July 18, 2023 09:24
@martintmk martintmk merged commit 8bc1658 into main Jul 18, 2023
10 checks passed
@martintmk martintmk deleted the mtomka/validator branch July 18, 2023 10:10
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