Abstractions
Namespace: RA.Utilities.Feature.Abstractions
The classes within the RA.Utilities.Feature.Abstractions namespace define the core interfaces for the CQRS pattern and the custom mediator.
✨ Purpose and Function
These interfaces form the contract between the mediator, your requests/notifications, and their handlers. They are the foundation upon which the Vertical Slice Architecture is built.
The primary abstractions are:
IRequest/IRequest<TResponse>: Marker interfaces for commands (no response) and queries (with response). Implement these on your request DTOs.IRequestHandler<TRequest>/IRequestHandler<TRequest, TResponse>: Interfaces your handlers implement. For a more convenient experience, inherit from the abstractRequestHandlerbase classes in theHandlersnamespace — they implement the interface plumbing so you only override oneHandleAsyncmethod.IPipelineBehavior<TRequest>/IPipelineBehavior<TRequest, TResponse>: Cross-cutting concerns that wrap request handler execution (validation, logging, etc.).INotification: Marker interface for events/notifications in the publish/subscribe system.INotificationHandler<TNotification>: Interface for notification subscribers.INotificationBehavior<TNotification>: Cross-cutting concerns that wrap notification handler execution (retry, metrics, logging).IMediator: The central dispatcher — sends requests and publishes notifications.
🧠 Summary
In summary, the RA.Utilities.Feature.Abstractions interfaces are the cornerstone of the CQRS pattern in this framework. For concrete handler implementations, see the Handlers namespace, which provides abstract base classes that handle the interface plumbing for you.
IRequest
IRequest and its generic counterpart IRequest are marker interfaces used to define the "messages" that your application sends. These messages can be either Commands (requests to change state) or Queries (requests to read data).
IRequestHandler
The primary purpose of an IRequestHandler is to contain the business logic for a single, specific feature (a command or a query).
IPipelineBehavior
The IPipelineBehavior interface defines a component that can participate in the processing of a request, allowing for the implementation of cross-cutting concerns.
INotification
The primary purpose of the INotification interface is to mark a class as a notification or event.
INotificationHandler
The INotificationHandler interface defines the contract for a class that handles a specific INotification.
INotificationBehavior
The INotificationBehavior interface defines a pipeline behavior that can be applied to the processing of an INotification.
IMediator
The IMediator interface is the central abstraction for dispatching requests and publishing notifications within your CQRS (Command Query Responsibility Segregation) architecture.
IPipeline VS INotification
How do IPipelineBehavior and INotificationBehavior