Class PollyServiceCollectionExtensions
- Namespace
- Polly
- Assembly
- Polly.Extensions.dll
Provides extension methods for registering resilience pipelines using the IServiceCollection.
public static class PollyServiceCollectionExtensions
- Inheritance
-
PollyServiceCollectionExtensions
- Inherited Members
Methods
AddResiliencePipelineRegistry<TKey>(IServiceCollection)
Adds ResiliencePipelineRegistry<TKey> and ResiliencePipelineProvider<TKey> to the service collection that allows configuring
and retrieving resilience pipelines using the TKey key.
public static IServiceCollection AddResiliencePipelineRegistry<TKey>(this IServiceCollection services) where TKey : notnull
Parameters
servicesIServiceCollectionThe IServiceCollection to add the resilience pipeline to.
Returns
- IServiceCollection
The updated IServiceCollection with additional services added.
Type Parameters
TKeyThe type of the key used to identify the resilience pipeline.
Remarks
This call enables telemetry for all resilience pipelines created using ResiliencePipelineRegistry<TKey>.
Exceptions
- ArgumentNullException
Thrown when
servicesis null.
AddResiliencePipelineRegistry<TKey>(IServiceCollection, Action<ResiliencePipelineRegistryOptions<TKey>>)
Adds ResiliencePipelineRegistry<TKey> and ResiliencePipelineProvider<TKey> to the service collection that allows configuring
and retrieving resilience pipelines using the TKey key.
public static IServiceCollection AddResiliencePipelineRegistry<TKey>(this IServiceCollection services, Action<ResiliencePipelineRegistryOptions<TKey>> configure) where TKey : notnull
Parameters
servicesIServiceCollectionThe IServiceCollection to add the resilience pipeline to.
configureAction<ResiliencePipelineRegistryOptions<TKey>>The action that configures the ResiliencePipelineRegistryOptions<TKey> that are used by the registry.
Returns
- IServiceCollection
The updated IServiceCollection with additional services added.
Type Parameters
TKeyThe type of the key used to identify the resilience pipeline.
Remarks
This call enables telemetry for all resilience pipelines created using ResiliencePipelineRegistry<TKey>.
Exceptions
- ArgumentNullException
Thrown when
servicesis null.
AddResiliencePipeline<TKey>(IServiceCollection, TKey, Action<ResiliencePipelineBuilder, AddResiliencePipelineContext<TKey>>)
Adds a resilience pipeline to service collection.
public static IServiceCollection AddResiliencePipeline<TKey>(this IServiceCollection services, TKey key, Action<ResiliencePipelineBuilder, AddResiliencePipelineContext<TKey>> configure) where TKey : notnull
Parameters
servicesIServiceCollectionThe IServiceCollection to add the resilience pipeline to.
keyTKeyThe key used to identify the resilience pipeline.
configureAction<ResiliencePipelineBuilder, AddResiliencePipelineContext<TKey>>An action that configures the resilience pipeline.
Returns
- IServiceCollection
The updated IServiceCollection with the registered resilience pipeline.
Type Parameters
TKeyThe type of the key used to identify the resilience pipeline.
Remarks
You can retrieve the registered pipeline by resolving the ResiliencePipelineProvider<TKey> class from the dependency injection container.
This call enables telemetry for the registered resilience pipeline.
Exceptions
- ArgumentNullException
Thrown when
servicesorconfigureis null.
AddResiliencePipeline<TKey>(IServiceCollection, TKey, Action<ResiliencePipelineBuilder>)
Adds a resilience pipeline to service collection.
public static IServiceCollection AddResiliencePipeline<TKey>(this IServiceCollection services, TKey key, Action<ResiliencePipelineBuilder> configure) where TKey : notnull
Parameters
servicesIServiceCollectionThe IServiceCollection to add the resilience pipeline to.
keyTKeyThe key used to identify the resilience pipeline.
configureAction<ResiliencePipelineBuilder>An action that configures the resilience pipeline.
Returns
- IServiceCollection
The updated IServiceCollection with the registered resilience pipeline.
Type Parameters
TKeyThe type of the key used to identify the resilience pipeline.
Remarks
You can retrieve the registered pipeline by resolving the ResiliencePipelineProvider<TKey> class from the dependency injection container.
This call enables telemetry for the registered resilience pipeline.
Exceptions
- ArgumentNullException
Thrown when
servicesorconfigureis null.
AddResiliencePipeline<TKey, TResult>(IServiceCollection, TKey, Action<ResiliencePipelineBuilder<TResult>, AddResiliencePipelineContext<TKey>>)
Adds a resilience pipeline that handles TResult to service collection.
public static IServiceCollection AddResiliencePipeline<TKey, TResult>(this IServiceCollection services, TKey key, Action<ResiliencePipelineBuilder<TResult>, AddResiliencePipelineContext<TKey>> configure) where TKey : notnull
Parameters
servicesIServiceCollectionThe IServiceCollection to add the resilience pipeline to.
keyTKeyThe key used to identify the resilience pipeline.
configureAction<ResiliencePipelineBuilder<TResult>, AddResiliencePipelineContext<TKey>>An action that configures the resilience pipeline.
Returns
- IServiceCollection
The updated IServiceCollection with the registered resilience pipeline.
Type Parameters
TKeyThe type of the key used to identify the resilience pipeline.
TResultThe type of result that the resilience pipeline handles.
Remarks
You can retrieve the registered pipeline by resolving the ResiliencePipelineProvider<TKey> class from the dependency injection container.
This call enables telemetry for the registered resilience pipeline.
Exceptions
- ArgumentNullException
Thrown when
servicesorconfigureis null.
AddResiliencePipeline<TKey, TResult>(IServiceCollection, TKey, Action<ResiliencePipelineBuilder<TResult>>)
Adds a resilience pipeline that handles TResult to service collection.
public static IServiceCollection AddResiliencePipeline<TKey, TResult>(this IServiceCollection services, TKey key, Action<ResiliencePipelineBuilder<TResult>> configure) where TKey : notnull
Parameters
servicesIServiceCollectionThe IServiceCollection to add the resilience pipeline to.
keyTKeyThe key used to identify the resilience pipeline.
configureAction<ResiliencePipelineBuilder<TResult>>An action that configures the resilience pipeline.
Returns
- IServiceCollection
The updated IServiceCollection with the registered resilience pipeline.
Type Parameters
TKeyThe type of the key used to identify the resilience pipeline.
TResultThe type of result that the resilience pipeline handles.
Remarks
You can retrieve the registered pipeline by resolving the ResiliencePipelineProvider<TKey> class from the dependency injection container.
This call enables telemetry for the registered resilience pipeline.
Exceptions
- ArgumentNullException
Thrown when
servicesorconfigureis null.
AddResiliencePipelines<TKey>(IServiceCollection, Action<AddResiliencePipelinesContext<TKey>>)
Allows deferred addition of one or more resilience pipelines to the service collection.
public static IServiceCollection AddResiliencePipelines<TKey>(this IServiceCollection services, Action<AddResiliencePipelinesContext<TKey>> configure) where TKey : notnull
Parameters
servicesIServiceCollectionThe IServiceCollection to add resilience pipelines to.
configureAction<AddResiliencePipelinesContext<TKey>>An action that allows configuration of resilience pipelines.
Returns
- IServiceCollection
The updated IServiceCollection with the addition configuration added.
Type Parameters
TKeyThe type of the key used to identify the resilience pipelines.
Remarks
This method can be useful if you want to add resilience pipelines as late as possible, e.g. to allow other services / configuration to be available before providing the key.
You can retrieve the registered pipeline by resolving the ResiliencePipelineProvider<TKey> class from the dependency injection container.
This call enables telemetry for the registered resilience pipeline.
Exceptions
- ArgumentNullException
Thrown when
servicesorconfigureis null.