Table of Contents

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> that allows configuring and retrieving resilience pipelines using the TKey key.

public static IServiceCollection AddResiliencePipelineRegistry<TKey>(this IServiceCollection services) where TKey : notnull

Parameters

services IServiceCollection

The IServiceCollection to add the resilience pipeline to.

Returns

IServiceCollection

The updated IServiceCollection with additional services added.

Type Parameters

TKey

The 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 services is null.

AddResiliencePipelineRegistry<TKey>(IServiceCollection, Action<ResiliencePipelineRegistryOptions<TKey>>)

Adds ResiliencePipelineRegistry<TKey> and ResiliencePipelineProvider<TKey> 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

services IServiceCollection

The IServiceCollection to add the resilience pipeline to.

configure Action<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

TKey

The 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 services is 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

services IServiceCollection

The IServiceCollection to add the resilience pipeline to.

key TKey

The key used to identify the resilience pipeline.

configure Action<ResiliencePipelineBuilder, AddResiliencePipelineContext<TKey>>

An action that configures the resilience pipeline.

Returns

IServiceCollection

The updated IServiceCollection with the registered resilience pipeline.

Type Parameters

TKey

The 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 the telemetry for the registered resilience pipeline.

Exceptions

InvalidOperationException

Thrown if the resilience pipeline builder with the provided key has already been added to the registry.

ArgumentNullException

Thrown when services or configure is 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

services IServiceCollection

The IServiceCollection to add the resilience pipeline to.

key TKey

The key used to identify the resilience pipeline.

configure Action<ResiliencePipelineBuilder>

An action that configures the resilience pipeline.

Returns

IServiceCollection

The updated IServiceCollection with the registered resilience pipeline.

Type Parameters

TKey

The 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 the telemetry for the registered resilience pipeline.

Exceptions

InvalidOperationException

Thrown if the resilience pipeline builder with the provided key has already been added to the registry.

ArgumentNullException

Thrown when services or configure is null.

AddResiliencePipeline<TKey, TResult>(IServiceCollection, TKey, Action<ResiliencePipelineBuilder<TResult>, AddResiliencePipelineContext<TKey>>)

Adds a generic resilience pipeline to service collection.

public static IServiceCollection AddResiliencePipeline<TKey, TResult>(this IServiceCollection services, TKey key, Action<ResiliencePipelineBuilder<TResult>, AddResiliencePipelineContext<TKey>> configure) where TKey : notnull

Parameters

services IServiceCollection

The IServiceCollection to add the resilience pipeline to.

key TKey

The key used to identify the resilience pipeline.

configure Action<ResiliencePipelineBuilder<TResult>, AddResiliencePipelineContext<TKey>>

An action that configures the resilience pipeline.

Returns

IServiceCollection

The updated IServiceCollection with the registered resilience pipeline.

Type Parameters

TKey

The type of the key used to identify the resilience pipeline.

TResult

The 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 the telemetry for the registered resilience pipeline.

Exceptions

InvalidOperationException

Thrown if the resilience pipeline builder with the provided key has already been added to the registry.

ArgumentNullException

Thrown when services or configure is null.

AddResiliencePipeline<TKey, TResult>(IServiceCollection, TKey, Action<ResiliencePipelineBuilder<TResult>>)

Adds a generic resilience pipeline to service collection.

public static IServiceCollection AddResiliencePipeline<TKey, TResult>(this IServiceCollection services, TKey key, Action<ResiliencePipelineBuilder<TResult>> configure) where TKey : notnull

Parameters

services IServiceCollection

The IServiceCollection to add the resilience pipeline to.

key TKey

The key used to identify the resilience pipeline.

configure Action<ResiliencePipelineBuilder<TResult>>

An action that configures the resilience pipeline.

Returns

IServiceCollection

The updated IServiceCollection with the registered resilience pipeline.

Type Parameters

TKey

The type of the key used to identify the resilience pipeline.

TResult

The 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 the telemetry for the registered resilience pipeline.

Exceptions

InvalidOperationException

Thrown if the resilience pipeline builder with the provided key has already been added to the registry.

ArgumentNullException

Thrown when services or configure is null.