A Go library implementing the mediator pattern for decoupled request/response and event handling, inspired by MediatR for .NET.
Go-MediatR is a Go library that implements the mediator pattern to facilitate decoupled communication between components in an application. It provides structured handling for request/response messages (commands and queries) and notifications (events), making it easier to adopt CQRS and event-driven architectures. The library is inspired by the popular MediatR library for .NET, bringing similar patterns to the Go ecosystem.
Go developers building applications with CQRS, event-driven architectures, or microservices who need a clean way to decouple components and manage cross-cutting concerns.
Developers choose Go-MediatR for its straightforward implementation of the mediator pattern, which reduces direct dependencies and improves testability. Its support for pipeline behaviors allows seamless integration of cross-cutting concerns like logging and metrics without cluttering business logic.
🚃 A library for handling mediator patterns and simplified CQRS patterns within an event-driven architecture, inspired by csharp MediatR library.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implements single-handler requests for commands and queries, enabling clean CQRS separation as demonstrated with CreateProductCommand and GetProductByIdQuery examples in the README.
Supports multiple handlers for events without responses, ideal for event-driven architectures, shown with ProductCreatedEvent and its handlers in the notification strategy section.
Pipeline behaviors allow middleware-like functionality such as logging and metrics, exemplified by RequestLoggerBehaviour that wraps handler execution.
Reduces direct dependencies between components, improving testability and maintainability, a core emphasis highlighted in the project's philosophy.
Requires explicit struct definitions and registration for each handler and message type, leading to increased code volume, as seen in the lengthy example snippets.
Lacks out-of-the-box features like validation, error handling strategies, or serialization, forcing developers to implement these manually, hinted by the 'validate' tags in command structs.
Heavy use of generics in interfaces and methods, such as RequestHandler and Send, can be confusing for those not adept with Go's type system, adding a learning curve.