Class BulkheadPolicy
- Namespace
- Excalibur.Dispatch.Resilience.Polly
- Assembly
- Excalibur.Dispatch.Resilience.Polly.dll
Bulkhead policy implementation using Polly.
public class BulkheadPolicy : IBulkheadPolicy, IDisposable, IAsyncDisposable
- Inheritance
-
BulkheadPolicy
- Implements
- Inherited Members
- Extension Methods
Constructors
BulkheadPolicy(string, BulkheadOptions, ILogger?)
Initializes a new instance of the BulkheadPolicy class.
public BulkheadPolicy(string name, BulkheadOptions options, ILogger? logger = null)
Parameters
namestringThe bulkhead identifier.
optionsBulkheadOptionsThe bulkhead configuration options.
loggerILoggerThe logger used for diagnostic output.
Properties
HasCapacity
Gets a value indicating whether the bulkhead has available capacity.
public bool HasCapacity { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Releases managed resources.
protected virtual void Dispose(bool disposing)
Parameters
DisposeAsync()
Asynchronously releases resources used by the bulkhead policy.
public ValueTask DisposeAsync()
Returns
ExecuteAsync<T>(Func<CancellationToken, Task<T>>, CancellationToken)
Executes an operation that observes both caller cancellation and its execution timeout.
public Task<T> ExecuteAsync<T>(Func<CancellationToken, Task<T>> operation, CancellationToken cancellationToken)
Parameters
operationFunc<CancellationToken, Task<T>>The operation, which must observe the supplied strategy token.
cancellationTokenCancellationTokenThe caller cancellation token.
Returns
- Task<T>
The operation result.
Type Parameters
TThe result type.
Remarks
Existing implementations retain the original overload and may implement this capability explicitly.
Exceptions
- NotSupportedException
The implementation does not support token-aware execution.
ExecuteAsync<T>(Func<Task<T>>, CancellationToken)
Executes an operation with bulkhead isolation.
public Task<T> ExecuteAsync<T>(Func<Task<T>> operation, CancellationToken cancellationToken)
Parameters
operationFunc<Task<T>>The delegate to execute within the bulkhead constraints.
cancellationTokenCancellationTokenA token used to observe cancellation requests.
Returns
- Task<T>
A task that completes with the asynchronous result produced by the operation.
Type Parameters
TThe type returned by the asynchronous
operation.
Remarks
This overload cannot supply the execution timeout token to the operation. Use the token-aware overload for cooperative cancellation; a timeout waits for the operation to finish cancelling.
GetMetrics()
Gets the current bulkhead metrics.
public BulkheadMetrics GetMetrics()
Returns
- BulkheadMetrics
The current BulkheadMetrics snapshot.