Categorygithub.com/mbict/go-cqrs/v4
modulepackage
4.0.0-beta.11
Repository: https://github.com/mbict/go-cqrs.git
Documentation: pkg.go.dev

# README

go-cqrs

Build Status GoDoc GoCover GoReportCard

CQRS/es implementation in go

Aggregates

todo

Commands

todo

Events

todo

Event store and streams

todo

Factories

todo

Aggregate repository

todo

Projections

todo

Middleware for command handler

todo

Event publishing

todo

Examples

Examples are in the _example directory.

Inventory example This is the GO version of the C# Simple CQRS example from Gregory Young.

Passing events by value not by pointer reference

Events are always passed by value, never passed by pointer reference. This is to ensure immutability of the events data.

  • The Load method of the aggregate repository will always convert pointer events and pass them by value to the aggregates Apply function.
  • The Save method of the aggregate repository will convert any pointer referenced events and pass them by value to the aggregate Apply method and to the publish event hooks (PublishEventFunc)

Always refer to the class name of an event in your aggregates and projections. Never to the pointer variant, it will probably never be picked up

EventFactory

The event factory must always return a pointer to the newly created event. This is of the event stream needs to scan/unmarshal the data into the event instance and can only do this for pointer instances. Later on the newly created event will be passed by value to the aggregates and or projections.

Todo

  • Test the domain aggregate repository.
  • More real world examples.
  • See how it performs in my projects.
  • Documentation documentation documentation.
  • Write test for Snapshot repository
  • Create Mysql and Postgres variant for SnapshotStore

# Packages

No description provided by the author
No description provided by the author

# Functions

AggregateCommandHandler is a command handler middleware who loads the aggregate calls the aggregate command handler to execute the business logic and saves the events to the aggregate store afterwards.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewAggregateRepository is the constructor of the repository publishEventHooks get called when a new event is successfully persisted to the eventstore.
NewCallbackAggregateFactory creates a new CallbackAggregateFactory.
NewCallbackEventFactory constructs a new CallbackEventFactory.
NewRepository instantiates a new repository resolver who accepts a stream resolver.
NewEvent constructor with plain version.
NewEventFromAggregate constructor will create a new event based on the latest aggregate state.
No description provided by the author
NewSnapshotAggregateRepository is the constructor of the aggregate repository with snapshot functionality A snapshot will be created when the differenceOffset between the snapshot version and the current version is equal or greater than the `differenceOffset` When the differenceOffset is set to 10 than: - aggregate version 7 (snapshot version 0) will not create a snapshot - aggregate version 10 (snapshot version 0) will create a snapshot for version 10 - aggregate version 13 (snapshot version 0) will create a snapshot for version 13 - aggregate version 21 (snapshot version 13) will not create a snapshot - aggregate version 54 (snapshot version 13) will create a snapshot for version 54.
SnapshotAggregateBuilder.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

CallbackAggregateFactory is an implementation of the AggregateFactory interface that supports registration of delegate/callback functions to perform aggregate instantiation.
CallbackEventFactory uses callback/delegate functions to instantiate event instances given the name of the event type as a string.
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
AggregateFactory returns aggregate instances of a specified type with the AggregateId set to the uuid provided.
AggregateHandlesCommands indicates a aggregate can directly handle a command.
AggregateRepository is the interface that a specific aggregate repositories should implement.
AggregateRepositoryManager is the managing interface who provide aggregate repository access.
No description provided by the author
Event.
EventData is the actual data of the event.
EventFactory is the interface that an event store should implement.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Validate is the interface an aggregate command can implement to perform validation prior to executing domain logic.

# Type aliases

AggregateBuilder is the builder function to create new aggregate compositions.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
EventFactoryFunc should create an Event and return the pointer to the instance.
No description provided by the author
No description provided by the author
No description provided by the author