CQRS
is a library that provides an implementation of the Command Query Responsibility Segregation (CQRS) pattern
for Go. It aims to help you create clean, modular, and scalable applications by separating the read and write concerns
of your domain.
The library is currently considered unstable as it hasn't reached v1.0.0
yet. However, it consists of both stable and
unstable components. The stable components are less likely to have their API changed, while the unstable components are
still under active development and might have breaking changes in the future. The unstable components can be found under
the x/
directory. Keep in mind that the whole library is under development, and it is recommended to always check the
latest changes and updates before using it in your projects.
To install the library, use the following command:
go get github.com/screwyprof/cqrs
One of the stable components is the aggregate
package, which provides a way to create event-sourced aggregates. An
aggregate is a domain object that processes commands and produces events as a result. Event sourcing means that the
aggregate's state is derived from its event history.
To use the aggregate
package, you'll need to define your own identifier and event types. The package provides a
FromAggregate
function to convert your domain aggregate into an event-sourced aggregate.
A runnable example demonstrating the usage of the aggregate
package can be found in the example_test.go
file
within the aggregate
package. This example showcases how to define your own domain aggregate, commands, and events,
and how to process commands and apply events using the event-sourced aggregate. More examples can be found in the
the examples
directory.
Full documentation can be found on GoDoc.
Contributions are welcome! If you have any suggestions, bug reports, or feature requests, please open a new issue or submit a pull request.
The Interactor Library is released under the MIT License.
This project was highly inspired by the following projects: