Event Horizon is a CQRS/ES toolkit for Go.
NOTE: Event Horizon is used in production systems but the API is not final!
CQRS stands for Command Query Responsibility Segregation and is a technique where object access (the Query part) and modification (the Command part) are separated from each other. This helps in designing complex data models where the actions can be totally independent from the data output.
ES stands for Event Sourcing and is a technique where all events that have happened in a system are recorded, and all future actions are based on the events instead of a single data model. The main benefit of adding Event Sourcing is traceability of changes which can be used for example in audit logging. Additionally, "incorrect" events that happened in the past (for example due to a bug) can be compensated for with an event which will make the current data "correct", as that is based on the events.
Read more about CQRS/ES from one of the major authors/contributors on the subject: http://codebetter.com/gregyoung/2010/02/16/cqrs-task-based-uis-event-sourcing-agh/
Other material on CQRS/ES:
- http://martinfowler.com/bliki/CQRS.html
- http://cqrs.nu
- https://groups.google.com/forum/#!forum/dddcqrs
Inspired by the following libraries/examples:
- https://github.com/edumentab/cqrs-starter-kit
- https://github.com/pjvds/go-cqrs
- http://www.codeproject.com/Articles/555855/Introduction-to-CQRS
- https://github.com/qandidate-labs/broadway
Suggestions are welcome!
See the example folder for a few examples to get you started.
These are the drivers for storage of events and entities.
There are simple in memory implementations of an event store and entity repo. These are meant for testing/experimentation.
Fairly mature, used in production. Note: This implementation has a document size limit of 16MB, which could lead to errors for large aggregates. If needed use the alternative version below
MongoDB-Document Per Event is an alternative to the MongoDB driver mentioned above. In the MongoDB-DPE driver, events for an aggregate are each saved in a separate document. This allows aggregate event histories larger than the maximum document size of MongoDB, which is 16MB. https://github.com/gjongenelen/eh-mongodb
https://github.com/seedboxtech/eh-dynamo
https://github.com/giautm/eh-pg
https://github.com/TerraSkye/eh-redis
These are the drivers for messaging, currently only publishers.
Fully synchrounos. Useful for testing/experimentation.
Experimental driver.
https://github.com/Kistler-Group/eh-kafka
https://github.com/v0id3r/eh-nats
To develop Event Horizon you need to have Docker and Docker Compose installed.
To start all needed services and run all tests, simply run make:
make
To manualy run the services and stop them:
make run_services
make stop_services
When the services are running testing can be done either locally or with Docker:
go test ./...
make test
make test_docker
make cover
The difference between make test
and go test ./...
is that make test
also does race detection.
- Join our slack channel (sign up here)
- Check out the contribution guidelines
Event Horizon is licensed under Apache License 2.0