Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrHandlerNil CommandHandler or QueryHandler is nil ErrHandlerNil = errors.New("cqrs: handler is nil") // ErrRegistered not register CommandHandler or QueryHandler ErrRegistered = errors.New("cqrs: handler registered") // ErrUnregistered is not register CommandHandler or QueryHandler ErrUnregistered = errors.New("cqrs: handler unregistered") // ErrArgsNil arguments is nil ErrArgsNil = errors.New("cqrs: arguments is nil") // ErrBusClosed bus was closed ErrBusClosed = errors.New("cqrs: bus was closed") // ErrUnimplemented handler is not implement CommandHandler or QueryHandler ErrUnimplemented = errors.New("cqrs: handler is not implement CommandHandler or QueryHandler") )
Functions ¶
This section is empty.
Types ¶
type Bus ¶ added in v1.3.2
type Bus interface {
// RegisterCommand register CommandHandler
RegisterCommand(handler any) error
// RegisterQuery register QueryHandler
RegisterQuery(handler any) error
// Exec synchronously executes a command
Exec(ctx context.Context, args any) error
// Query synchronously executes a query
Query(ctx context.Context, args any) (any, error)
// AsyncExec asynchronously executes a command, result in Future
AsyncExec(ctx context.Context, args any) (Future, error)
// AsyncQuery asynchronously executes a query, result in Future
AsyncQuery(ctx context.Context, args any) (Future, error)
// Close bus gracefully
Close(ctx context.Context) error
}
Bus is a bus, register CommandHandler and QueryHandler, execute Command and query Query
type CommandHandler ¶
CommandHandler is a command handler that to update data.
type CommandHandlerFunc ¶
The CommandHandlerFunc type is an adapter to allow the use of ordinary functions as CommandHandler.
type Future ¶ added in v1.3.2
type Future interface {
// Get wait for computation completion, and to retrieve the result of the computation.
Get(ctx context.Context) (any, error)
}
Future represents the result of an asynchronous computation.
type NoopCommand ¶ added in v1.3.2
type NoopCommand[Args any] struct{}
NoopCommand is an CommandHandler that does nothing and returns a nil error.
type NoopQuery ¶ added in v1.2.5
NoopQuery is an QueryHandler that does nothing and returns a nil error.
type QueryHandler ¶
type QueryHandler[Args any, Result any] interface { Handle(ctx context.Context, args Args) (Result, error) }
QueryHandler is a query handler that to handlers to read data.
type QueryHandlerFunc ¶
The QueryHandlerFunc type is an adapter to allow the use of ordinary functions as QueryHandler.
Click to show internal directories.
Click to hide internal directories.