Documentation
¶
Index ¶
- Variables
- type App
- func (app *App) CommandBus() CommandBusPort
- func (app *App) EventBus() EventBusPort
- func (app *App) HandleCommand(t CommandType, f CommandHandlerFunc)
- func (app *App) HandleEvent(t EventType, f EventHandlerFunc)
- func (app *App) HandleQuery(t QueryType, f QueryHandlerFunc)
- func (app *App) QueryBus() QueryBusPort
- func (app *App) WithLogger(logger *slog.Logger) *App
- type Command
- type CommandBus
- type CommandBusPort
- type CommandController
- func (c *CommandController) Close() error
- func (c *CommandController) Commands(w http.ResponseWriter, r *http.Request)
- func (c *CommandController) Metrics(w http.ResponseWriter, r *http.Request)
- func (c *CommandController) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (c *CommandController) Types(w http.ResponseWriter, r *http.Request)
- func (c *CommandController) WithLogger(logger *slog.Logger) *CommandController
- type CommandDecoder
- type CommandHandler
- type CommandHandlerFunc
- type CommandType
- type Controller
- type Event
- type EventBus
- type EventBusPort
- type EventController
- func (e *EventController) Close() error
- func (c *EventController) Events(w http.ResponseWriter, r *http.Request)
- func (c *EventController) Metrics(w http.ResponseWriter, r *http.Request)
- func (c *EventController) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (c *EventController) Types(w http.ResponseWriter, r *http.Request)
- func (c *EventController) WithConfig(config EventControllerConfig) *EventController
- func (c *EventController) WithLogger(logger *slog.Logger) *EventController
- type EventControllerConfig
- type EventEncoder
- type EventHandler
- type EventHandlerFunc
- type EventType
- type Query
- type QueryBus
- type QueryBusPort
- type QueryCodec
- type QueryController
- func (c *QueryController) Close() error
- func (c *QueryController) Metrics(w http.ResponseWriter, r *http.Request)
- func (c *QueryController) Queries(w http.ResponseWriter, r *http.Request)
- func (c *QueryController) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (c *QueryController) Types(w http.ResponseWriter, r *http.Request)
- func (c *QueryController) WithLogger(logger *slog.Logger) *QueryController
- type QueryHandler
- type QueryHandlerFunc
- type QueryType
- type Result
- type ResultEncoder
- type TraceID
Constants ¶
This section is empty.
Variables ¶
var ( ErrEventHandler = errors.New("cqrs: failed to handle event") ErrUnknownCommandType = errors.New("cqrs: unknown command type") ErrUnknownQueryType = errors.New("cqrs: unknown query type") ErrUnimplementedHandler = errors.New("cqrs: unimplemented handler") ErrPanicRecovered = errors.New("cqrs: panic recovered") )
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func New ¶ added in v1.2.0
func New(cb CommandBusPort, qb QueryBusPort, eb EventBusPort) *App
func (*App) CommandBus ¶ added in v1.2.0
func (app *App) CommandBus() CommandBusPort
func (*App) EventBus ¶ added in v1.2.0
func (app *App) EventBus() EventBusPort
func (*App) HandleCommand ¶
func (app *App) HandleCommand(t CommandType, f CommandHandlerFunc)
func (*App) HandleEvent ¶
func (app *App) HandleEvent(t EventType, f EventHandlerFunc)
func (*App) HandleQuery ¶
func (app *App) HandleQuery(t QueryType, f QueryHandlerFunc)
func (*App) QueryBus ¶ added in v1.2.0
func (app *App) QueryBus() QueryBusPort
type CommandBus ¶
type CommandBus struct {
// contains filtered or unexported fields
}
func NewCommandBus ¶
func NewCommandBus() *CommandBus
func (*CommandBus) Handle ¶ added in v1.2.0
Handle implements CommandHandler.
func (*CommandBus) HandleFunc ¶
func (cb *CommandBus) HandleFunc(t CommandType, f CommandHandlerFunc)
HandleFunc implements CommandBusPort.
func (*CommandBus) WithLogger ¶ added in v1.2.0
func (cb *CommandBus) WithLogger(logger *slog.Logger) *CommandBus
type CommandBusPort ¶ added in v1.2.0
type CommandBusPort interface {
CommandHandler
HandleFunc(CommandType, CommandHandlerFunc)
}
CommandBus
type CommandController ¶ added in v1.2.0
type CommandController struct {
// contains filtered or unexported fields
}
func NewCommandController ¶ added in v1.2.0
func NewCommandController(bus CommandBusPort, decoders map[CommandType]CommandDecoder) *CommandController
func (*CommandController) Close ¶ added in v1.2.0
func (c *CommandController) Close() error
Close implements CommandController.
func (*CommandController) Commands ¶ added in v1.2.0
func (c *CommandController) Commands(w http.ResponseWriter, r *http.Request)
func (*CommandController) Metrics ¶ added in v1.2.0
func (c *CommandController) Metrics(w http.ResponseWriter, r *http.Request)
func (*CommandController) ServeHTTP ¶ added in v1.2.0
func (c *CommandController) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements CommandController.
func (*CommandController) Types ¶ added in v1.2.0
func (c *CommandController) Types(w http.ResponseWriter, r *http.Request)
func (*CommandController) WithLogger ¶ added in v1.2.0
func (c *CommandController) WithLogger(logger *slog.Logger) *CommandController
type CommandDecoder ¶ added in v1.1.1
type CommandHandler ¶
CommandHandler
type CommandHandlerFunc ¶
CommandHandlerFunc
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(cc *CommandController, ec *EventController, qc *QueryController) *Controller
func (*Controller) Close ¶
func (c *Controller) Close() error
func (*Controller) ServeHTTP ¶ added in v1.2.0
func (c *Controller) ServeHTTP(w http.ResponseWriter, r *http.Request)
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
func NewEventBus ¶
func NewEventBus() *EventBus
func (*EventBus) Handle ¶ added in v1.2.0
Handle implements EventHandler.
func (*EventBus) HandleFunc ¶
func (eb *EventBus) HandleFunc(t EventType, f EventHandlerFunc)
HandleFunc implements EventBusPort.
type EventBusPort ¶ added in v1.2.0
type EventBusPort interface {
EventHandler
HandleFunc(EventType, EventHandlerFunc)
}
EventBus
type EventController ¶ added in v1.2.0
type EventController struct {
// contains filtered or unexported fields
}
func NewEventController ¶ added in v1.2.0
func NewEventController(bus EventBusPort, encoders map[EventType]EventEncoder) *EventController
func (*EventController) Close ¶ added in v1.2.0
func (e *EventController) Close() error
func (*EventController) Events ¶ added in v1.2.0
func (c *EventController) Events(w http.ResponseWriter, r *http.Request)
func (*EventController) Metrics ¶ added in v1.2.0
func (c *EventController) Metrics(w http.ResponseWriter, r *http.Request)
func (*EventController) ServeHTTP ¶ added in v1.2.0
func (c *EventController) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements EventController.
func (*EventController) Types ¶ added in v1.2.0
func (c *EventController) Types(w http.ResponseWriter, r *http.Request)
func (*EventController) WithConfig ¶ added in v1.2.0
func (c *EventController) WithConfig(config EventControllerConfig) *EventController
func (*EventController) WithLogger ¶ added in v1.2.0
func (c *EventController) WithLogger(logger *slog.Logger) *EventController
type EventControllerConfig ¶ added in v1.2.0
type EventControllerConfig struct {
MaxEventBufferSize int
}
type EventEncoder ¶ added in v1.1.1
type EventHandler ¶
EventHandler
type QueryBus ¶
type QueryBus struct {
// contains filtered or unexported fields
}
func NewQueryBus ¶
func NewQueryBus() *QueryBus
func (*QueryBus) Handle ¶ added in v1.2.0
Handle implements QueryHandler.
func (*QueryBus) HandleFunc ¶
func (qb *QueryBus) HandleFunc(t QueryType, f QueryHandlerFunc)
HandleFunc implements QueryBusPort.
type QueryBusPort ¶ added in v1.2.0
type QueryBusPort interface {
QueryHandler
HandleFunc(QueryType, QueryHandlerFunc)
}
QueryBus
type QueryCodec ¶ added in v1.2.0
type QueryController ¶ added in v1.2.0
type QueryController struct {
// contains filtered or unexported fields
}
func NewQueryController ¶ added in v1.2.0
func NewQueryController(bus QueryBusPort, codecs map[QueryType]QueryCodec) *QueryController
func (*QueryController) Close ¶ added in v1.2.0
func (c *QueryController) Close() error
Close implements QueryController.
func (*QueryController) Metrics ¶ added in v1.2.0
func (c *QueryController) Metrics(w http.ResponseWriter, r *http.Request)
func (*QueryController) Queries ¶ added in v1.2.0
func (c *QueryController) Queries(w http.ResponseWriter, r *http.Request)
func (*QueryController) ServeHTTP ¶ added in v1.2.0
func (c *QueryController) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements QueryController.
func (*QueryController) Types ¶ added in v1.2.0
func (c *QueryController) Types(w http.ResponseWriter, r *http.Request)
func (*QueryController) WithLogger ¶ added in v1.2.0
func (c *QueryController) WithLogger(logger *slog.Logger) *QueryController
type QueryHandler ¶
QueryHandler
type QueryHandlerFunc ¶
QueryHandlerFunc