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 #1087

Closed
martintmk opened this issue Mar 27, 2023 · 0 comments
Closed

Introduce Polly.Extensions project #1087

martintmk opened this issue Mar 27, 2023 · 0 comments
Assignees
Labels
v8 Issues related to the new version 8 of the Polly library.
Milestone

Comments

@martintmk
Copy link
Contributor

martintmk commented Mar 27, 2023

The Polly.Extensions projects integrates the Polly with the standard IServiceCollection DI container and implements the ResilienceTelemetryFactory thus enabling the telemetry for all resilience strategies created using the DI extension points.

Example:

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);
    });

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

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

// use your strategy

The consumer just calls the AddResilienceStrategy and provides a callback that configures the resilience strategy.

Optionally, the project can be also named Polly.DependencyInjection, however, the implementation of ResilienceTelemetryFactory shouldn't really belong there in that case.

@martintmk martintmk self-assigned this Mar 27, 2023
@martintmk martintmk converted this from a draft issue Mar 27, 2023
@martintmk martintmk added the v8 Issues related to the new version 8 of the Polly library. label Mar 27, 2023
@martintmk martintmk added this to the v8.0.0 milestone Mar 27, 2023
@martintmk martintmk changed the title Introduce Polly.Hosting project Introduce Polly.Extensions project Mar 30, 2023
@juraj-blazek juraj-blazek moved this to In Progress in Polly v8 Apr 11, 2023
@martintmk martintmk moved this from In Progress to Done in Polly v8 Apr 12, 2023
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

No branches or pull requests

1 participant