Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dispatcher ¶
type Dispatcher interface {
Dispatch(context.Context, ...Event) error // Dispatch given events to appropriate handlers.
}
Represents an element capable of dispatching domain events somewhere.
func NewInProcessDispatcher ¶
func NewInProcessDispatcher(handlers ...Handler) Dispatcher
Instantiates a dispatcher which will dispatch events synchronously to the given handlers and returns early if an error has been thrown by one handler.
This is the simplest dispatcher I can think of. It is mostly used to trigger usecases on some domain events to make them easier to test and reason about in isolation.
type Emitter ¶
type Emitter struct {
// contains filtered or unexported fields
}
Implements the Source interface, embed it in your own entities to enable functions such as `Store` and `Unwrap`.
I really like this solution because it does not poluate the domain stuff by exposing methods on entities. You have to explicitly ask for it.
type Event ¶
type Event any
Event triggered by main aggregates. This type is mostly a precaution in case required metadata evolve afterwards.
type Source ¶
type Source interface {
// contains filtered or unexported methods
}
Represents an event source which contains events before dispatching. Methods are unexported to avoid polluting the domain entities with those considerations for external clients.
You may use `Store` and `Unwrap` to manipulate a struct which embed an `Emitter`.