You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
varservices=newServiceCollection();// define your strategyservices.AddResilienceStrategy("my-key",
context =>context.Builder.AddTimeout(TimeSpan.FromSeconds(10)));// define your strategy using custom optionsservices.AddResilienceStrategy("my-timeout",
context =>{varmyOptions=context.ServiceProvider.GetRequiredService<IOptions<MyTimeoutOptions>>().Value;context.Builder.AddTimeout(myOptions.Timeout);});// use your strategyvarserviceProvider=services.BuildServiceProvider();varstrategyProvider=serviceProvider.GetRequiredService<ResilienceStrategyProvider<string>>();varresilienceStrategy=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.
The text was updated successfully, but these errors were encountered:
The
Polly.Extensions
projects integrates the Polly with the standardIServiceCollection
DI container and implements theResilienceTelemetryFactory
thus enabling the telemetry for all resilience strategies created using the DI extension points.Example:
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 ofResilienceTelemetryFactory
shouldn't really belong there in that case.The text was updated successfully, but these errors were encountered: