Documentation
¶
Index ¶
- func CommandEndpoint[C any](h CommandHandler[C]) endpoint.Endpoint[C, emptyResponse]
- func QueryEndpoint[Q any, R any](h QueryHandler[Q, R]) endpoint.Endpoint[Q, R]
- type CommandHandler
- type CommandHandlerFunc
- type CommandMiddleware
- type CommandMiddlewareFunc
- type NoopQuery
- type QueryHandler
- type QueryHandlerFunc
- type QueryMiddleware
- type QueryMiddlewareFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommandEndpoint ¶ added in v1.2.5
func CommandEndpoint[C any](h CommandHandler[C]) endpoint.Endpoint[C, emptyResponse]
CommandEndpoint convert CommandHandler to Endpoint
func QueryEndpoint ¶ added in v1.2.5
func QueryEndpoint[Q any, R any](h QueryHandler[Q, R]) endpoint.Endpoint[Q, R]
QueryEndpoint convert QueryHandler to Endpoint
Types ¶
type CommandHandler ¶
CommandHandler is a command handler that to update data. Commands should be task-based, rather than data centric. Commands may be placed on a queue for asynchronous processing, rather than being processed synchronously.
func ChainCommandHandler ¶
func ChainCommandHandler[C any](handler CommandHandler[C], middlewares ...CommandMiddleware[C]) CommandHandler[C]
ChainCommandHandler decorates the given CommandHandler with all middlewares.
type CommandHandlerFunc ¶
The CommandHandlerFunc type is an adapter to allow the use of ordinary functions as CommandHandler. If f is a function with the appropriate signature, CommandHandlerFunc(f) is a CommandHandler that calls f.
type CommandMiddleware ¶ added in v1.2.5
type CommandMiddleware[C any] interface { // Decorate wraps the underlying Command, adding some functionality. Decorate(handler CommandHandler[C]) CommandHandler[C] }
CommandMiddleware allows us to write something like decorators to CommandHandler. It can execute something before Handle or after.
type CommandMiddlewareFunc ¶ added in v1.2.5
type CommandMiddlewareFunc[C any] func(handler CommandHandler[C]) CommandHandler[C]
The CommandMiddlewareFunc type is an adapter to allow the use of ordinary functions as CommandMiddleware. If f is a function with the appropriate signature, CommandMiddlewareFunc(f) is a CommandMiddleware that calls f.
func (CommandMiddlewareFunc[C]) Decorate ¶ added in v1.2.5
func (f CommandMiddlewareFunc[C]) Decorate(handler CommandHandler[C]) CommandHandler[C]
Decorate call f(cmd).
type NoopQuery ¶ added in v1.2.5
NoopQuery is an QueryHandler that does nothing and returns a nil error.
type QueryHandler ¶
QueryHandler is a query handler that to queries to read data. Queries never modify the database. A query returns a DTO that does not encapsulate any domain knowledge.
func ChainQueryHandler ¶
func ChainQueryHandler[Q any, R any](handler QueryHandler[Q, R], middlewares ...QueryMiddleware[Q, R]) QueryHandler[Q, R]
ChainQueryHandler decorates the given QueryHandler with all middlewares.
type QueryHandlerFunc ¶
The QueryHandlerFunc type is an adapter to allow the use of ordinary functions as QueryHandler. If f is a function with the appropriate signature, QueryHandlerFunc(f) is a QueryHandler that calls f.
type QueryMiddleware ¶ added in v1.2.5
type QueryMiddleware[Q any, R any] interface { // Decorate wraps the underlying Command, adding some functionality. Decorate(QueryHandler[Q, R]) QueryHandler[Q, R] }
QueryMiddleware allows us to write something like decorators to QueryHandler. It can execute something before Handle or after.
type QueryMiddlewareFunc ¶ added in v1.2.5
type QueryMiddlewareFunc[Q any, R any] func(QueryHandler[Q, R]) QueryHandler[Q, R]
The QueryMiddlewareFunc type is an adapter to allow the use of ordinary functions as QueryMiddleware. If f is a function with the appropriate signature, QueryMiddlewareFunc(f) is a QueryMiddleware that calls f.
func (QueryMiddlewareFunc[Q, R]) Decorate ¶ added in v1.2.5
func (f QueryMiddlewareFunc[Q, R]) Decorate(handler QueryHandler[Q, R]) QueryHandler[Q, R]
Decorate call f(cmd).