Skip to content

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.

Guides & Recipes — Resilience

Recommended patterns for resilient Mediator commands and database retry presets.

using System;
using System.Threading;
using System.Threading.Tasks;
using EricksonLopez.Mediator;
using EricksonLopez.Resilience.Mediator.Contracts;
using EricksonLopez.Result;
namespace Example.ResilienceRecipes;
public sealed record ChargePaymentCommand(Guid OrderId, decimal Amount)
: ICommand<Result<string>>, IResilientRequest
{
public string ResiliencePolicy => "payments-api";
}
public sealed class ChargePaymentHandler : ICommandHandler<ChargePaymentCommand, Result<string>>
{
public ValueTask<Result<string>> Handle(
ChargePaymentCommand command,
CancellationToken cancellationToken) =>
ValueTask.FromResult(Result<string>.Success("authorized"));
}

Register services.AddResiliencePipelineBehavior() alongside services.AddEricksonLopezResilience(...) so every IResilientRequest executes through its named policy automatically.

Use .AddDatabaseResilience(timeout, maxRetries: 3) inside options.AddPolicy("postgres-rw", ...) to combine bounded execution timeouts with exponential jitter retries tuned for transient database faults.