Skip to main content
Table of Contents

Class ResilienceBehaviorServiceCollectionExtensions

Namespace
Microsoft.Extensions.DependencyInjection
Assembly
Stratara.Resilience.dll

DI extension that hooks Stratara's named Polly resilience pipelines into the in-process mediator pipeline via an opt-in, per-request behavior.

public static class ResilienceBehaviorServiceCollectionExtensions
Inheritance
ResilienceBehaviorServiceCollectionExtensions
Inherited Members

Methods

AddStrataraResilienceBehavior(IServiceCollection)

Register the resilience pipeline behavior so any mediator request implementing IResilientRequest is dispatched inside the named Polly pipeline it selects. Requests that do not implement the marker are unaffected.

public static IServiceCollection AddStrataraResilienceBehavior(this IServiceCollection services)

Parameters

services IServiceCollection

The service collection to mutate.

Returns

IServiceCollection

The same service collection, to enable chaining.

Examples

Acts only on requests implementing IResilientRequest; everything else passes through:

services.AddResiliencePipelines();
services.AddStrataraResilienceBehavior();

Remarks

Requires the named pipelines to be registered (AddResiliencePipelines(IServiceCollection) or a consumer's own AddResiliencePipeline(name, ...)) and the mediator to be added. Call this after AddStrataraValidation() / AddStrataraTenantIsolation() so the retry wraps the handler and not the validation / authorization guards (which should not be re-run on retry). Behaviors are open generics resolved per request. Calling this more than once installs the behavior once, so a request is not retried twice over.