How jbogard/mediatr works
Main Components
a) Core Components:
• Mediator (Central Hub)
• Request/Response Pipeline
• Notification Pipeline
• Stream Pipeline
• Service Registration System
b) Key Interfaces:
• IMediator
• ISender
• IPublisher
• IRequest/IRequestHandler
• INotification/INotificationHandler
• IStreamRequest/IStreamRequestHandler
Architectural Patterns to Highlight
• Mediator Pattern (core pattern)
• Pipeline Pattern (for request/notification processing)
• Publisher/Subscriber Pattern (for notifications)
• Chain of Responsibility (for behaviors)
[Client Application] → [MediatR Registration (DI)]
[ISender] →[Mediator]← [IPublisher]
[Pre-Processors] → [Behaviors] → [Handlers] → [Post-Processors]
[Request Handlers] [Notification Handlers] [Stream Handlers]
Special Elements
• Exception Handling Pipeline
• Stream Processing Pipeline
• Notification Publishing Strategies
Detailed Component Relationships
[Client] → [IMediator]
• ↓
[Pipeline Behaviors]
• ↓
[Pre-Processors]
• ↓
[Request/Notification Processing]
• ↓
[Post-Processors]
• ↓
[Response/Notification Dispatch]
Important Notes
• Variance support in the generic handlers
• Different notification publishing strategies
• Pipeline behavior ordering
• Separation between synchronous and asynchronous flows
• Exception handling pipeline integration
Implementation Details
• Service registration flow
• Handler resolution process
• Pipeline behavior chaining
• Exception handling integration
• Stream processing specifics