Table of Contents

Class PolicyExtensions

Namespace
LMKit.Agents.Resilience
Assembly
LM-Kit.NET.dll

Extension methods for building policy compositions.

public static class PolicyExtensions
Inheritance
PolicyExtensions
Inherited Members

Examples

Composing retry, timeout, and circuit-breaker into one policy chain:

using LMKit.Agents.Resilience;

IResiliencePolicy policy = new RetryPolicy(maxAttempts: 3) .WithTimeout(TimeSpan.FromSeconds(30)) .WrapWith(new CircuitBreakerPolicy(failuresBeforeOpen: 5, openDuration: TimeSpan.FromMinutes(1)));

var result = await policy.ExecuteAsync(ct => agent.RunAsync("Generate report", ct));

Methods

WithCircuitBreaker(IResiliencePolicy, int, TimeSpan?)

Adds a circuit breaker to this policy.

WithRetry(IResiliencePolicy, int)

Adds retry to this policy.

WithTimeout(IResiliencePolicy, TimeSpan)

Adds a timeout to this policy.

WrapWith(IResiliencePolicy, IResiliencePolicy)

Wraps this policy with another policy.

Share