class
CircuitBreakerMiddleware
Assembly: EricksonLopez.Messagingpublic sealed class CircuitBreakerMiddleware : IMessageMiddleware
Implements: IMessageMiddleware
Provides circuit breaker resilience middleware to halt message processing when failure thresholds are breached.
Members (3)
constructorCircuitBreakerMiddleware
public CircuitBreakerMiddleware(CircuitBreakerOptions options, ILogger<CircuitBreakerMiddleware>? logger = null)
Initializes a new instance of the `CircuitBreakerMiddleware` class with explicit options.
- options: CircuitBreakerOptions
- The circuit breaker configuration options.
- logger: ILogger<CircuitBreakerMiddleware>?
- The logger instance, if specified.
constructorCircuitBreakerMiddleware
public CircuitBreakerMiddleware(IOptions<CircuitBreakerOptions>? options = null, ILogger<CircuitBreakerMiddleware>? logger = null)
Initializes a new instance of the `CircuitBreakerMiddleware` class with the specified options and logger.
- options: IOptions<CircuitBreakerOptions>?
- The circuit breaker configuration options.
- logger: ILogger<CircuitBreakerMiddleware>?
- The logger instance, if specified.
methodInvokeAsync
public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)
Invokes the middleware logic and continues execution along the pipeline.
- context: MessageContext
- The ambient message execution context.
- next: MessageExecutionDelegate
- The delegate representing the next step in the pipeline.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.
class
CircuitBreakerOptions
Assembly: EricksonLopez.Messagingpublic sealed class CircuitBreakerOptions
Specifies configuration options for `CircuitBreakerMiddleware`.
Members (5)
propertyBreakDuration
public TimeSpan BreakDuration { get; set; }
Gets or sets the duration the circuit remains open before transitioning to the half-open state.
propertyFailureFilter
public Func<Error, bool>? FailureFilter { get; set; }
Gets or sets an optional predicate to determine whether an error should be considered a failure for the circuit breaker. When `null`, all `Result` failures are treated as failures.
propertyFailureThreshold
public int FailureThreshold { get; set; }
Gets or sets the consecutive failure count threshold required to trip the circuit open.
propertySamplingDuration
public TimeSpan SamplingDuration { get; set; }
Gets or sets the observation window within which consecutive failures are counted toward the threshold.
propertyTimeProvider
public TimeProvider? TimeProvider { get; set; }
Gets or sets an optional time provider override for elapsed-time calculations.
class
ExceptionHandlingMiddleware
Assembly: EricksonLopez.Messagingpublic sealed class ExceptionHandlingMiddleware : IMessageMiddleware
Implements: IMessageMiddleware
Provides safety middleware that catches unhandled exceptions during handler execution and converts them into functional `Result` failures.
Members (1)
methodInvokeAsync
public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)
Invokes the middleware logic and continues execution along the pipeline.
- context: MessageContext
- The ambient message execution context.
- next: MessageExecutionDelegate
- The delegate representing the next step in the pipeline.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.
class
HandlerTimeoutMiddleware
Assembly: EricksonLopez.Messagingpublic sealed class HandlerTimeoutMiddleware : IMessageMiddleware
Implements: IMessageMiddleware
Provides timeout middleware enforcing maximum execution limits on message handler invocations via linked cancellation tokens.
Members (3)
constructorHandlerTimeoutMiddleware
public HandlerTimeoutMiddleware(HandlerTimeoutOptions options, ILogger<HandlerTimeoutMiddleware>? logger = null)
Initializes a new instance of the `HandlerTimeoutMiddleware` class with explicit options.
- options: HandlerTimeoutOptions
- The timeout configuration options.
- logger: ILogger<HandlerTimeoutMiddleware>?
- The logger instance, if specified.
constructorHandlerTimeoutMiddleware
public HandlerTimeoutMiddleware(IOptions<HandlerTimeoutOptions>? options = null, ILogger<HandlerTimeoutMiddleware>? logger = null)
Initializes a new instance of the `HandlerTimeoutMiddleware` class with the specified options and logger.
- options: IOptions<HandlerTimeoutOptions>?
- The timeout configuration options.
- logger: ILogger<HandlerTimeoutMiddleware>?
- The logger instance, if specified.
methodInvokeAsync
public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)
Invokes the middleware logic and continues execution along the pipeline.
- context: MessageContext
- The ambient message execution context.
- next: MessageExecutionDelegate
- The delegate representing the next step in the pipeline.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.
class
HandlerTimeoutOptions
Assembly: EricksonLopez.Messagingpublic sealed class HandlerTimeoutOptions
Specifies configuration options for `HandlerTimeoutMiddleware`.
Members (2)
propertyTimeProvider
public TimeProvider? TimeProvider { get; set; }
Gets or sets an optional time provider override for timeout cancellation scheduling.
propertyTimeout
public TimeSpan Timeout { get; set; }
Gets or sets the maximum execution duration allowed for message processing before cancelling the operation.
interface
IMessageMiddleware
Assembly: EricksonLopez.Messagingpublic interface IMessageMiddleware
Defines an interceptor middleware component in the message consumption pipeline.
Members (1)
methodInvokeAsync
ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)
Invokes the middleware logic and continues execution along the pipeline.
- context: MessageContext
- The ambient message execution context.
- next: MessageExecutionDelegate
- The delegate representing the next step in the pipeline.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.
interface
IMessageUpcasterInvoker
Assembly: EricksonLopez.Messagingpublic interface IMessageUpcasterInvoker
Defines non-generic invocation of registered message upcasters during pipeline execution.
Members (3)
methodUpcast
object Upcast(object message, TransportMessageMetadata metadata, IServiceProvider serviceProvider)
Transforms the source message instance to its upgraded schema target.
- message: object
- The source message instance.
- metadata: TransportMessageMetadata
- The message metadata.
- serviceProvider: IServiceProvider
- The service provider for dependency resolution.
Returns: The upgraded message instance.
propertySourceType
Type SourceType { get; }
Gets the source message type from which this upcaster transforms.
propertyTargetType
Type TargetType { get; }
Gets the target message type to which this upcaster transforms.
class
InMemoryMessageDeduplicationStore
Assembly: EricksonLopez.Messagingpublic sealed class InMemoryMessageDeduplicationStore : IMessageDeduplicationStore, IDisposable
Implements: IDisposable, IMessageDeduplicationStore
Provides a high-performance in-memory, thread-safe implementation of `IMessageDeduplicationStore` with bounded capacity and Least Recently Used (LRU) eviction.
Members (11)
constructorInMemoryMessageDeduplicationStore
public InMemoryMessageDeduplicationStore()
Initializes a new instance with default capacity (100,000) and system time provider.
constructorInMemoryMessageDeduplicationStore
public InMemoryMessageDeduplicationStore(IOptions<MessageDeduplicationOptions>? options, TimeProvider? timeProvider = null)
Initializes a new instance with custom options from dependency injection.
- options: IOptions<MessageDeduplicationOptions>?
- The configured deduplication options.
- timeProvider: TimeProvider?
- The optional time provider instance.
constructorInMemoryMessageDeduplicationStore
public InMemoryMessageDeduplicationStore(int maxCapacity)
Initializes a new instance with custom maximum capacity.
- maxCapacity: int
- The maximum capacity before LRU eviction occurs.
constructorInMemoryMessageDeduplicationStore
public InMemoryMessageDeduplicationStore(int maxCapacity, TimeProvider? timeProvider)
Initializes a new instance of the `InMemoryMessageDeduplicationStore` class with custom capacity and time provider.
- maxCapacity: int
- The maximum number of entries before LRU eviction triggers.
- timeProvider: TimeProvider?
- The time provider instance.
constructorInMemoryMessageDeduplicationStore
public InMemoryMessageDeduplicationStore(TimeProvider? timeProvider)
Initializes a new instance with a custom time provider and default capacity.
- timeProvider: TimeProvider?
- The time provider instance.
methodDispose
public void Dispose()
Releases the resources used by this instance.
methodReleaseAsync
public ValueTask ReleaseAsync(string messageId, CancellationToken cancellationToken = default)
Releases the idempotency lock for the specified message identity, allowing it to be retried.
- messageId: string
- The unique identity of the message.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation.
methodTryAcquireAsync
public ValueTask<bool> TryAcquireAsync(string messageId, TimeSpan expiration, CancellationToken cancellationToken = default)
Attempts to acquire an idempotency lock for the specified message identity.
- messageId: string
- The unique identity of the message.
- expiration: TimeSpan
- The maximum duration to retain the deduplication state.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains `true` if the lock was successfully acquired; otherwise, `false` if the message is a duplicate.
propertyCount
public int Count { get; }
Gets the number of entries currently stored.
propertyMaxCapacity
public int MaxCapacity { get; }
Gets the maximum capacity of the in-memory store before LRU eviction occurs.
fieldDefaultMaxCapacity
public const int DefaultMaxCapacity
Specifies the default maximum number of entries (100,000) retained in memory before LRU eviction occurs.
class
LoggingMiddleware
Assembly: EricksonLopez.Messagingpublic sealed class LoggingMiddleware : IMessageMiddleware
Implements: IMessageMiddleware
Provides structured logging middleware for the message processing pipeline.
Members (2)
constructorLoggingMiddleware
public LoggingMiddleware(ILogger<LoggingMiddleware>? logger = null)
Initializes a new instance of the `LoggingMiddleware` class with the specified logger.
- logger: ILogger<LoggingMiddleware>?
- The logger instance, if specified.
methodInvokeAsync
public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)
Invokes the middleware logic and continues execution along the pipeline.
- context: MessageContext
- The ambient message execution context.
- next: MessageExecutionDelegate
- The delegate representing the next step in the pipeline.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.
class
MessageDeduplicationMiddleware
Assembly: EricksonLopez.Messagingpublic sealed class MessageDeduplicationMiddleware : IMessageMiddleware
Implements: IMessageMiddleware
Intercepts incoming messages to detect and suppress duplicate executions based on message identity.
Members (2)
constructorMessageDeduplicationMiddleware
public MessageDeduplicationMiddleware(IMessageDeduplicationStore store, IOptions<MessageDeduplicationOptions>? options = null, ILogger<MessageDeduplicationMiddleware>? logger = null)
Initializes a new instance of the `MessageDeduplicationMiddleware` class.
- store: IMessageDeduplicationStore
- The deduplication state store.
- options: IOptions<MessageDeduplicationOptions>?
- The deduplication options.
- logger: ILogger<MessageDeduplicationMiddleware>?
- The diagnostic logger.
methodInvokeAsync
public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)
Invokes the middleware logic and continues execution along the pipeline.
- context: MessageContext
- The ambient message execution context.
- next: MessageExecutionDelegate
- The delegate representing the next step in the pipeline.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.
class
MessageDeduplicationOptions
Assembly: EricksonLopez.Messagingpublic sealed class MessageDeduplicationOptions
Configures message deduplication behavior in the message processing pipeline.
Members (3)
propertyEnabled
public bool Enabled { get; set; }
Gets or sets a value indicating whether message deduplication is actively enforced.
propertyExpiration
public TimeSpan Expiration { get; set; }
Gets or sets the duration for which processed message identifiers are retained to prevent duplicate handling. The default is 24 hours.
propertyMaxCapacity
public int MaxCapacity { get; set; }
Gets or sets the maximum number of message identifiers retained in memory before LRU eviction occurs. Default is 100,000.
delegate
MessageExecutionDelegate
Assembly: EricksonLopez.Messagingpublic delegate ValueTask<Result> MessageExecutionDelegate(MessageContext context, CancellationToken cancellationToken)
Inherits: System.MulticastDelegate
Encapsulates an asynchronous continuation step in the message processing middleware pipeline.
Members (0)
This type declares 0 public members (e.g. marker interface or empty enum/record).
class
MessageUpcasterInvoker<TOld, TNew, TUpcaster>
Assembly: EricksonLopez.Messagingpublic sealed class MessageUpcasterInvoker<TOld, TNew, TUpcaster> : IMessageUpcasterInvoker where TOld : class, IMessage where TNew : class, IMessage where TUpcaster : class, IMessageUpcaster<TOld, TNew>
Implements: IMessageUpcasterInvoker
Adapts `IMessageUpcaster<TOldMessage, TNewMessage>` implementations to `IMessageUpcasterInvoker`.
Members (3)
methodUpcast
public object Upcast(object message, TransportMessageMetadata metadata, IServiceProvider serviceProvider)
Transforms the source message instance to its upgraded schema target.
- message: object
- The source message instance.
- metadata: TransportMessageMetadata
- The message metadata.
- serviceProvider: IServiceProvider
- The service provider for dependency resolution.
Returns: The upgraded message instance.
propertySourceType
public Type SourceType { get; }
Gets the source message type from which this upcaster transforms.
propertyTargetType
public Type TargetType { get; }
Gets the target message type to which this upcaster transforms.
class
MessageUpcastingMiddleware
Assembly: EricksonLopez.Messagingpublic sealed class MessageUpcastingMiddleware : IMessageMiddleware
Implements: IMessageMiddleware
Provides middleware that detects legacy message schemas and applies registered upcasters to migrate payloads to the current contract version.
Members (2)
constructorMessageUpcastingMiddleware
public MessageUpcastingMiddleware(IEnumerable<IMessageUpcasterInvoker> upcasters, ILogger<MessageUpcastingMiddleware>? logger = null)
Initializes a new instance of the `MessageUpcastingMiddleware` class with the specified upcasters and logger.
- upcasters: IEnumerable<IMessageUpcasterInvoker>
- The collection of registered message upcaster invokers.
- logger: ILogger<MessageUpcastingMiddleware>?
- The logger instance, if specified.
methodInvokeAsync
public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)
Invokes the middleware logic and continues execution along the pipeline.
- context: MessageContext
- The ambient message execution context.
- next: MessageExecutionDelegate
- The delegate representing the next step in the pipeline.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.
class
MiddlewarePipeline
Assembly: EricksonLopez.Messagingpublic sealed class MiddlewarePipeline
Encapsulates a pipeline executor chaining registered middlewares and the terminal handler invocation.
Members (3)
constructorMiddlewarePipeline
public MiddlewarePipeline(IEnumerable<IMessageMiddleware>? middlewares = null)
Initializes a new instance of the `MiddlewarePipeline` class with the specified middlewares.
- middlewares: IEnumerable<IMessageMiddleware>?
- The collection of middleware components to include in the pipeline.
methodBuildChain
public MessageExecutionDelegate BuildChain(MessageExecutionDelegate terminalHandler)
Composes the middleware chain ending with the specified terminal handler. This builds and returns a pre-chained `MessageExecutionDelegate` that can be cached and executed repeatedly on hot dispatch paths with zero delegate or closure allocations.
- terminalHandler: MessageExecutionDelegate
- The terminal handler delegate to execute at the end of the pipeline.
Returns: The composed delegate pipeline ready for zero-allocation execution.
methodExecuteAsync
public ValueTask<Result> ExecuteAsync(MessageContext context, MessageExecutionDelegate terminalHandler, CancellationToken cancellationToken = default)
Executes the middleware pipeline terminating at the specified terminal handler delegate.
- context: MessageContext
- The ambient message execution context.
- terminalHandler: MessageExecutionDelegate
- The terminal handler delegate to execute at the end of the pipeline.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.
class
RetryMiddleware
Assembly: EricksonLopez.Messagingpublic sealed class RetryMiddleware : IMessageMiddleware
Implements: IMessageMiddleware
Provides retry middleware with exponential backoff and full-jitter randomization for transient processing failures.
Members (3)
constructorRetryMiddleware
public RetryMiddleware(RetryOptions options)
Initializes a new instance of the `RetryMiddleware` class with the specified `RetryOptions`.
- options: RetryOptions
- The configuration options for the retry logic.
constructorRetryMiddleware
public RetryMiddleware(int maxRetries = 3, TimeSpan? initialDelay = null, TimeProvider? timeProvider = null, TimeSpan? maxDelay = null, Func<Error, bool>? shouldRetry = null)
Initializes a new instance of the `RetryMiddleware` class with the specified retry parameters.
- maxRetries: int
- The maximum number of retry attempts before the last attempt is allowed to propagate. Values less than zero are clamped to zero, meaning no retries occur.
- initialDelay: TimeSpan?
- The base delay used as the ceiling for full-jitter calculation. The ceiling doubles on each attempt. Defaults to 100 milliseconds when `null`.
- timeProvider: TimeProvider?
- An optional time provider used for delay scheduling. When `null`, `TimeProvider.System` is used.
- maxDelay: TimeSpan?
- The maximum allowable delay ceiling between attempts. Defaults to 1 minute when `null`.
- shouldRetry: Func<Error, bool>?
- An optional predicate to determine whether a failed `Result` should be retried.
methodInvokeAsync
public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)
Invokes the middleware logic and continues execution along the pipeline.
- context: MessageContext
- The ambient message execution context.
- next: MessageExecutionDelegate
- The delegate representing the next step in the pipeline.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.
class
RetryOptions
Assembly: EricksonLopez.Messagingpublic sealed class RetryOptions
Specifies configuration options for `RetryMiddleware`.
Members (5)
propertyInitialDelay
public TimeSpan InitialDelay { get; set; }
Gets or sets the base delay applied before the first retry attempt. Subsequent delays are calculated using an exponential backoff formula with full-jitter randomization.
propertyMaxDelay
public TimeSpan MaxDelay { get; set; }
Gets or sets the maximum delay cap applied to any retry attempt.
propertyMaxRetries
public int MaxRetries { get; set; }
Gets or sets the maximum number of retry attempts before the final attempt is allowed to propagate. Values less than zero are clamped to zero, meaning no retries occur.
propertyShouldRetry
public Func<Error, bool>? ShouldRetry { get; set; }
Gets or sets an optional predicate to determine whether a failed `Result` should be retried. When `null`, all non-successful outcomes are retried.
propertyTimeProvider
public TimeProvider? TimeProvider { get; set; }
Gets or sets an optional time provider override for delay scheduling.
class
TracingMiddleware
Assembly: EricksonLopez.Messagingpublic sealed class TracingMiddleware : IMessageMiddleware
Implements: IMessageMiddleware
Provides OpenTelemetry distributed tracing and metrics middleware for message processing.
Members (1)
methodInvokeAsync
public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)
Invokes the middleware logic and continues execution along the pipeline.
- context: MessageContext
- The ambient message execution context.
- next: MessageExecutionDelegate
- The delegate representing the next step in the pipeline.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.