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 Polly.Extensions project #1088

Merged
merged 12 commits into from
Apr 3, 2023
Merged

Introduce Polly.Extensions project #1088

merged 12 commits into from
Apr 3, 2023

Conversation

martintmk
Copy link
Contributor

@martintmk martintmk commented Mar 28, 2023

The issue or feature being addressed

#1087

Details on the issue fix or feature implementation

Enables the configuration of ResilienceStrategy using the DI and additional extensibility. The API exposes only a single AddResilienceStrategy public extension for IServiceCollecion. Additional extensibility can be done using IOptions pattern.

var services = new ServiceCollection();

// define your strategy
services.AddResilienceStrategy(
  "my-key", 
   context => context.Builder.AddTimeout(TimeSpan.FromSeconds(10)));

// define your strategy using custom options
services.AddResilienceStrategy(
    "my-timeout",
    context =>
    {
        var myOptions = context.ServiceProvider.GetRequiredService<IOptions<MyTimeoutOptions>>().Value;
        context.Builder.AddTimeout(myOptions.Timeout);
    });

// configure global builder options that will be shared for all builders
services.Configure<ResilienceStrategyBuilderOptions>(options =>
{
    options.Properties.Set(new ResiliencePropertyKey<string>("my-key"), "shared-value");
});

// configure the default telemetry factory
services.TryAddSingleton<ResilienceTelemetryFactory, MyTelemetryFactory>();

// use your strategy
var serviceProvider = services.BuildServiceProvider();
var strategyProvider = serviceProvider.GetRequiredService<ResilienceStrategyProvider<string>>();

var resilienceStrategy = strategyProvider.Get("my-key");

// use your strategy

Additional Changes:

  • using net462 target (net461 is out of support and some packages complained).

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

@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2023

Codecov Report

Merging #1088 (1f95bd9) into main (2f84eab) will increase coverage by 0.06%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main    #1088      +/-   ##
==========================================
+ Coverage   75.04%   75.10%   +0.06%     
==========================================
  Files         173      173              
  Lines        4243     4254      +11     
  Branches      790      791       +1     
==========================================
+ Hits         3184     3195      +11     
  Misses        854      854              
  Partials      205      205              
Flag Coverage Δ
linux 75.10% <100.00%> (+0.06%) ⬆️
macos 75.10% <100.00%> (?)
windows 75.10% <100.00%> (+0.06%) ⬆️

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

Impacted Files Coverage Δ
...y.Core/Builder/ResilienceStrategyBuilderOptions.cs 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

src/Directory.Packages.props Outdated Show resolved Hide resolved
src/Polly.Hosting/README.md Outdated Show resolved Hide resolved
src/Polly.Hosting/README.md Outdated Show resolved Hide resolved
src/Polly.Hosting/README.md Outdated Show resolved Hide resolved
src/Polly/Polly.csproj Show resolved Hide resolved
@martincostello martincostello added this to the v8.0.0 milestone Mar 28, 2023
@martintmk martintmk added the v8 Issues related to the new version 8 of the Polly library. label Mar 28, 2023
@martintmk martintmk self-assigned this Mar 28, 2023
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netstandard2.0;net472;net462</TargetFrameworks>
<AssemblyTitle>Polly.Hosting</AssemblyTitle>

Choose a reason for hiding this comment

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

Polly.Hosting doesn't sound right => Polly.Extensions?
We could then follow the familiar pattern with Polly.Extensions.DependencyInjection

@martintmk martintmk changed the title Introduce Polly.Hosting project Introduce Polly.Extensions project Mar 30, 2023
@martincostello
Copy link
Member

Just my two outstanding comments from yesterday.

@martintmk
Copy link
Contributor Author

Just my two outstanding comments from yesterday.

@martincostello Sorry, but I do not see any that I did not respond to. Are they lost somewhere? :)

@martincostello
Copy link
Member

This one and the other it turns out wasn't submitted 😅

#1088 (comment)

@martintmk martintmk merged commit 1241a4a into main Apr 3, 2023
@martintmk martintmk deleted the mtomka/polly.hosting branch April 3, 2023 13:28
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.

4 participants