{"id":19282213,"url":"https://github.com/theskyinflames/cqrs-eda","last_synced_at":"2025-04-22T01:31:30.556Z","repository":{"id":64535982,"uuid":"570198170","full_name":"theskyinflames/cqrs-eda","owner":"theskyinflames","description":"DDD, CQRS and Even-Driven lib for Go","archived":false,"fork":false,"pushed_at":"2023-08-25T06:43:12.000Z","size":42,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T23:03:47.269Z","etag":null,"topics":["concurrency","cqrs","cqrs-architectural-pattern","cqrs-pattern","eda","event-driven","event-driven-architecture","event-driven-microservices","go-service","golang","golang-library","goroutine","goroutine-pool","hexagonal-architecture"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theskyinflames.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-24T15:04:53.000Z","updated_at":"2024-10-02T16:34:35.000Z","dependencies_parsed_at":"2024-06-20T15:52:57.744Z","dependency_job_id":null,"html_url":"https://github.com/theskyinflames/cqrs-eda","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theskyinflames%2Fcqrs-eda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theskyinflames%2Fcqrs-eda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theskyinflames%2Fcqrs-eda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theskyinflames%2Fcqrs-eda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theskyinflames","download_url":"https://codeload.github.com/theskyinflames/cqrs-eda/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250162025,"owners_count":21385026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","cqrs","cqrs-architectural-pattern","cqrs-pattern","eda","event-driven","event-driven-architecture","event-driven-microservices","go-service","golang","golang-library","goroutine","goroutine-pool","hexagonal-architecture"],"created_at":"2024-11-09T21:25:48.405Z","updated_at":"2025-04-22T01:31:30.168Z","avatar_url":"https://github.com/theskyinflames.png","language":"Go","funding_links":["https://www.buymeacoffee.com/jaumearus"],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/theskyinflames/cqrs-eda)](https://goreportcard.com/report/github.com/theskyinflames/cqrs-eda)\n\n# CQRS - EDA - DDD\nThis repo contains a set of tools to implement CQRS/EDA DDD oriented services. This tooling is composed of:\n\n* CQRS utils:\n    * Command, command handler\n    * Command middleware\n    * Query, query handler\n    * Query handler middleware\n* EDA:\n    * Events basic\n    * Events listener\n* Bus:\n    * Sequential generic bus\n    * Concurrent generic bus\n\n## CQRS\n[CQRS](https://learn.microsoft.com/en-us/azure/architecture/patterns/cqrs) is a pattern that allows isolating the operations that modify the domain state, called *Commands*, from those that don't, called *Queries*. As a result of a *Command* execution, one or more domain events will be published.\n\nAs commands as queries are handled by specialized handlers called *Command Handler* and *Query Handler* respectively.\n\nIn some documentation, CQRS uses a read model as a separate infrastructure that serves queries, but I don't see it this way. You can use  CQRS without that, and it only makes sense when you need to split R/W operations on your domain.\n\n### C/Q handler middlewares\nCommandHandler and QueryHandler middlewares are used to intercept the flux to and from the handler. They help inject handler dependencies and react to the handler return. There is a simple example of middleware that prints handler-returned errors. Another option is to wrap command handlers in a DB TX middleware in charge of starting a transaction, pass it to the command handler, and rollbacking or committing the tx depending on whether the command handler fails.\n\nIt is a pattern that allows the C/Q handler taking care only of what is its responsibility as application services\n\nYou will find the CQRS tooling in [pkg/cqrs](pkg/cqrs) directory.\n\n## Events and EDA\n[EDA](https://en.wikipedia.org/wiki/Event-driven_architecture) stands for *Event-Driven-Architecture* It's an architectural pattern that allows decoupling the command handler that executes the command, and hence, the one that changes the domain, from those that react to this change. These reacting command handlers can belong to the same service or not. This decoupling is achieved by domain events publishing.\n\nYou will find the Events tooling in [pkg/events](pkg/events) directory.\n\n### Events listener\nThe events tooling includes an events listener implementation. It's in charge of listening to a specific event and dispatching it to an event handler. Usually, this event handler will map the event to a command and call a command handler to react to the domain change notified by the event.\n\nTake into account that the tradeoff of EDA architectures is [eventual consistency](https://en.wikipedia.org/wiki/Eventual_consistency)\n\n## Bus and Hexagonal Architecture\nAs CQRS architectures as EDA ones, use a bus:\n\n* CQRS uses a command/query bus to dispatch the commands and queries from the entry point, usually an HTTP or RCP API. It allows the decoupling of the infra layer from the application layer where command and query handlers live.\n\n* For EDA architectures, when event consumers live in the same bounded context (same service), they're usually dispatched to an Event bus, which is in charge of delegating them to the corresponding event handlers. Usually, these event handlers will map the event to a command and dispatch it to the command bus.\n\nYou will find the Bus tooling in [pkg/bus](pkg/bus) directory.\n\n### Bus implementations\nThere are two bus implementations: a sequential and a concurrent. Use the first one if you don't have performance issues related to events dispatching.\n\n## Examples\nI've implemented some examples to help you to understand how to use this tooling:\n\n* [command_bus](examples/concurrent_bus) Example of a command dispatched to a command bus using the sequential bus.\n\n* [event_bus](examples/events_bus) Example of an event dispatched to a sequential event bus.\n\n* [concurrent_event_bus](examples/concurrent_event_bus) Example of two events dispatched to a concurrent event bus.\n\n## Do you think this is useful? back me up\nThinking and building this tool has taken part of my time and effort. If you find it useful, and you think I deserve it, you can invite me a coffee :-)\n\n \u003ca href=\"https://www.buymeacoffee.com/jaumearus\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy Me A Coffee\" height=\"41\" width=\"174\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheskyinflames%2Fcqrs-eda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheskyinflames%2Fcqrs-eda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheskyinflames%2Fcqrs-eda/lists"}