Documentation
¶
Index ¶
- type AppError
- type BasicAggregateRoot
- type BasicEvent
- type Command
- type CommandHandler
- type CommandHandlerFunc
- type CommandHandlerMiddleware
- type Event
- type EventBus
- type EventFactory
- type EventListener
- type EventName
- type EventsRepositoryError
- type InvalidCommandError
- type InvalidQueryError
- type Query
- type QueryHandler
- type QueryHandlerMiddleware
- type QueryName
- type UnknownEventToDispatchError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppError ¶
type AppError struct {
Name string `json:"name"`
Input interface{} `json:"input"`
ErrMsg string `json:"err_msg"`
}
AppError is a query/command hnd error with context
type BasicAggregateRoot ¶
type BasicAggregateRoot struct {
// contains filtered or unexported fields
}
func NewBasicAggregateRoot ¶
func NewBasicAggregateRoot() BasicAggregateRoot
NewBasicAggregateRoot is a constructor
func (*BasicAggregateRoot) ClearEvents ¶
func (b *BasicAggregateRoot) ClearEvents()
ClearEvents removes all events from the aggregate root. It's exported for testing purposes.
func (BasicAggregateRoot) CreatedAt ¶
func (b BasicAggregateRoot) CreatedAt() vo.Time
CreatedAt is a getter
func (*BasicAggregateRoot) Events ¶
func (b *BasicAggregateRoot) Events() []Event
Events is a getter
func (*BasicAggregateRoot) Hydrate ¶
func (b *BasicAggregateRoot) Hydrate(createdAt vo.Time, events []Event)
Hydrate fills the BasicAggregateRoot fields
func (*BasicAggregateRoot) Record ¶
func (b *BasicAggregateRoot) Record(evs ...Event)
type BasicEvent ¶
type BasicEvent struct {
IDAttr uuid.UUID `json:"id"`
NameAttr EventName `json:"name"`
AtAttr vo.Time `json:"at"`
AggregateRootIDAttr string `json:"aggregate_root_id"`
}
BasicEvent is the minimal domain event struct.
func NewBasicEvent ¶
func NewBasicEvent(name EventName, id uuid.UUID, aggRootID string) BasicEvent
NewBasicEvent is the constructor for the type.
func (BasicEvent) AggregateRootID ¶
func (b BasicEvent) AggregateRootID() string
AggregateRootID is a getter
type Command ¶
type Command interface {
Name() string
}
Command is the interface for identifying commands by name.
type CommandHandler ¶
CommandHandler is self-described
type CommandHandlerFunc ¶
CommandHandlerFunc is a function that implements CommandHandler interface.
type CommandHandlerMiddleware ¶
type CommandHandlerMiddleware func(h CommandHandler) CommandHandler
func CommandHandlerMultiMiddleware ¶
func CommandHandlerMultiMiddleware(middlewares ...CommandHandlerMiddleware) CommandHandlerMiddleware
CommandHandlerMultiMiddleware applies a sequence of middlewares to a given command handler.
func NewCommandHndErrorMiddleware ¶
func NewCommandHndErrorMiddleware(logger *zerolog.Logger) CommandHandlerMiddleware
type Event ¶
type Event interface {
EventID() uuid.UUID
EventName() string
EventAt() vo.Time
AggregateRootID() string
}
Event is self-described
type EventBus ¶
type EventBus map[string][]EventListener
EventBus subscribe events with event listeners, and dispatch them.
func (EventBus) Subscribe ¶
func (e EventBus) Subscribe(ev Event, listeners ...EventListener)
Subscribe map event to event listeners
type EventListener ¶
EventListener is self-described
type EventsRepositoryError ¶
type EventsRepositoryError struct {
// contains filtered or unexported fields
}
EventsRepositoryError is self-described
func NewEventsRepositoryError ¶
func NewEventsRepositoryError(operation string, err error) EventsRepositoryError
NewEventsRepositoryError is a constructor
func (EventsRepositoryError) Error ¶
func (e EventsRepositoryError) Error() string
type InvalidCommandError ¶
type InvalidCommandError struct {
// contains filtered or unexported fields
}
InvalidCommandError should be returned by the implementations of the interface when the handler does not receive the needed command.
func NewInvalidCommandError ¶
func NewInvalidCommandError(expected string, had string) InvalidCommandError
NewInvalidCommandError is a constructor
func (InvalidCommandError) Error ¶
func (e InvalidCommandError) Error() string
type InvalidQueryError ¶
type InvalidQueryError struct {
// contains filtered or unexported fields
}
InvalidQueryError is self-described
func NewInvalidQueryError ¶
func NewInvalidQueryError(expected string, had string) InvalidQueryError
NewInvalidQueryError is a constructor
func (InvalidQueryError) Error ¶
func (e InvalidQueryError) Error() string
type Query ¶
type Query interface {
Name() string
}
Query is the interface to identify the DTO for a given query by name.
type QueryHandler ¶
QueryHandler is the interface for handling queries.
type QueryHandlerMiddleware ¶
type QueryHandlerMiddleware func(h QueryHandler) QueryHandler
QueryHandlerMiddleware is a type for decorating QueryHandlers
func NewQueryHndErrorMiddleware ¶
func NewQueryHndErrorMiddleware(logger *zerolog.Logger) QueryHandlerMiddleware
NewQueryHndErrorMiddleware is a middleware constructor to log a contextualized query handler error
type QueryName ¶
type QueryName string
QueryName is string to identify a given query when it has not input parameters.
type UnknownEventToDispatchError ¶
type UnknownEventToDispatchError struct {
// contains filtered or unexported fields
}
UnknownEventToDispatchError is self-described
func (UnknownEventToDispatchError) Error ¶
func (u UnknownEventToDispatchError) Error() string