Documentation ¶
Index ¶
Constants ¶
const (
EndOfStream = 0
)
Version constants
const (
NoVersion = 0
)
NoVersion constants
Variables ¶
var (
ErrNotCommandHandler = errors.New("AggregateNotHandler")
)
Errors
Functions ¶
Types ¶
type AggregateFactory ¶
type AggregateFactory func() Aggregate
AggregateFactory creates a brand new aggregate when called
type CommandHandler ¶
CommandHandler is anything that can take in a command a return events based on it
type CommandModel ¶
type CommandModel struct {
ID string
}
CommandModel implements the Command interface
func (CommandModel) AggregateID ¶
func (c CommandModel) AggregateID() string
AggregateID implements the Command interface
type EventModel ¶
EventModel implements the Event interface
func (EventModel) AggregateID ¶
func (e EventModel) AggregateID() string
AggregateID implements the Event interface
func (EventModel) EventAt ¶
func (e EventModel) EventAt() time.Time
EventAt implements the Event interface
func (EventModel) EventVersion ¶
func (e EventModel) EventVersion() int
EventVersion implements the Event interface
type EventNamer ¶
type EventNamer interface {
EventName() string
}
EventNamer is an event that can name itself
type JSONSerializer ¶
type JSONSerializer struct {
// contains filtered or unexported fields
}
JSONSerializer implements the Serializer interface
func NewJSONSerializer ¶
func NewJSONSerializer(events ...Event) *JSONSerializer
NewJSONSerializer serializes events into/out of JSON, it uses reflection to get the new events and so events should not have any behaviour depending on some initialization like a custom constructor
func (*JSONSerializer) Deserialize ¶
func (s *JSONSerializer) Deserialize(record Record) (Event, error)
Deserialize implements the Serializer interface
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository interface
func New ¶
func New(factory AggregateFactory, options ...RepositoryOption) *Repository
New creates a new repository with the given aggregate and options
func (*Repository) Dispatch ¶
Dispatch is a helper function that applies a command to an aggregate and saves the events. The aggregate must implement the CommandHandler interface
type RepositoryOption ¶
type RepositoryOption func(*Repository)
RepositoryOption applies a different option onto the repository
func WithSerializer ¶
func WithSerializer(s Serializer) RepositoryOption
WithSerializer adds a custom serializer to the repository
func WithStore ¶
func WithStore(s Store) RepositoryOption
WithStore adds a custom store to the repository