Table of Contents

Class BulkheadPolicy

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

A resilience policy that limits concurrent executions.

Prevents resource exhaustion by limiting how many operations can execute simultaneously.

public sealed class BulkheadPolicy : IResiliencePolicy, IDisposable
Inheritance
BulkheadPolicy
Implements
Inherited Members
Extension Methods

Examples

var bulkhead = new BulkheadPolicy(maxConcurrency: 5, maxQueueSize: 10);

// Only 5 concurrent executions, 10 queued
var tasks = inputs.Select(input => 
    bulkhead.ExecuteAsync(ct => agent.RunAsync(input, ct)));

await Task.WhenAll(tasks);

Constructors

BulkheadPolicy(int, int)

Initializes a new instance of the BulkheadPolicy class.

Properties

AvailableSlots

Gets the available execution slots.

CurrentExecutions

Gets the current number of executing operations.

CurrentQueueSize

Gets the current queue size.

MaxConcurrency

Gets the maximum concurrent executions.

MaxQueueSize

Gets the maximum queue size.

Name

Gets the name of this policy.

Methods

Dispose()

Disposes the policy.

ExecuteAsync<T>(Func<ResilienceContext, CancellationToken, Task<T>>, ResilienceContext, CancellationToken)

Executes an action with this policy and context.

ExecuteAsync<T>(Func<CancellationToken, Task<T>>, CancellationToken)

Executes an action with this policy applied.

OnRejected(Action<int, int>)

Sets a callback for when operations are rejected.