Documentation ¶
Index ¶
- Constants
- Variables
- func ServiceProvider() service.Provider
- type BaseCommand
- type BaseCommandResult
- type BaseQuery
- type BaseQueryResult
- type Command
- type CommandFactory
- type CommandHandler
- type CommandHandlerFunc
- type CommandID
- type CommandMiddleware
- type CommandRequest
- type CommandResult
- type CommandResultFactory
- type Dispatcher
- func (d *Dispatcher) Exec(ctx context.Context, req CommandRequest) (CommandResult, error)
- func (d *Dispatcher) Query(ctx context.Context, req QueryRequest) (QueryResult, error)
- func (d *Dispatcher) RegisterCommand(match MatchFunc, hdlr CommandHandler, mdlwrs ...CommandMiddleware)
- func (d *Dispatcher) RegisterQuery(match MatchFunc, hdlr QueryHandler, mdlwrs ...QueryMiddleware)
- type MatchFunc
- type Option
- type OptionFunc
- type Query
- type QueryFactory
- type QueryHandler
- type QueryHandlerFunc
- type QueryID
- type QueryMiddleware
- type QueryRequest
- type QueryResult
- type QueryResultFactory
- type Registry
- func (r *Registry) MatchCommand(cmd Command) (CommandHandler, []CommandMiddleware, error)
- func (r *Registry) MatchQuery(qry Query) (QueryHandler, []QueryMiddleware, error)
- func (r *Registry) RegisterCommand(match MatchFunc, hdlr CommandHandler, mdlwrs ...CommandMiddleware)
- func (r *Registry) RegisterQuery(match MatchFunc, hdlr QueryHandler, mdlwrs ...QueryMiddleware)
Constants ¶
View Source
const ServiceName service.Name = "cqrs"
ServiceName defines the cqrs service name
Variables ¶
Functions ¶
func ServiceProvider ¶
ServiceProvider returns a service.Provider for the the cqrs service
Types ¶
type BaseCommand ¶
type BaseCommand struct {
// contains filtered or unexported fields
}
func NewBaseCommand ¶
func NewBaseCommand(req CommandRequest) *BaseCommand
func (*BaseCommand) ID ¶
func (c *BaseCommand) ID() CommandID
func (*BaseCommand) Request ¶
func (c *BaseCommand) Request() CommandRequest
type BaseCommandResult ¶
type BaseCommandResult struct {
// contains filtered or unexported fields
}
func NewBaseCommandResult ¶
func NewBaseCommandResult(cmd Command) *BaseCommandResult
func (*BaseCommandResult) Command ¶
func (r *BaseCommandResult) Command() Command
type BaseQuery ¶
type BaseQuery struct {
// contains filtered or unexported fields
}
func NewBaseQuery ¶
func NewBaseQuery(req QueryRequest) *BaseQuery
func (*BaseQuery) Request ¶
func (q *BaseQuery) Request() QueryRequest
type BaseQueryResult ¶
type BaseQueryResult struct {
// contains filtered or unexported fields
}
func NewBaseQueryResult ¶
func NewBaseQueryResult(qry Query, data interface{}) *BaseQueryResult
func (*BaseQueryResult) Data ¶
func (r *BaseQueryResult) Data() interface{}
func (*BaseQueryResult) Query ¶
func (r *BaseQueryResult) Query() Query
type Command ¶
type Command interface { ID() CommandID Request() CommandRequest }
type CommandFactory ¶
type CommandFactory func(CommandRequest) (Command, error)
type CommandHandlerFunc ¶
type CommandMiddleware ¶
type CommandMiddleware func(next CommandHandler) CommandHandler
type CommandRequest ¶
type CommandRequest interface { }
type CommandResult ¶
type CommandResult interface {
Command() Command
}
type CommandResultFactory ¶
type CommandResultFactory func(Command) (CommandResult, error)
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func From ¶
func From(container *service.Container) (*Dispatcher, error)
From retrieves the cqrs service in the given container
func Must ¶
func Must(container *service.Container) *Dispatcher
Must retrieves the cqrs service in the given container or panic otherwise
func NewDispatcher ¶
func NewDispatcher(funcs ...OptionFunc) *Dispatcher
func (*Dispatcher) Exec ¶
func (d *Dispatcher) Exec(ctx context.Context, req CommandRequest) (CommandResult, error)
func (*Dispatcher) Query ¶
func (d *Dispatcher) Query(ctx context.Context, req QueryRequest) (QueryResult, error)
func (*Dispatcher) RegisterCommand ¶
func (d *Dispatcher) RegisterCommand(match MatchFunc, hdlr CommandHandler, mdlwrs ...CommandMiddleware)
func (*Dispatcher) RegisterQuery ¶
func (d *Dispatcher) RegisterQuery(match MatchFunc, hdlr QueryHandler, mdlwrs ...QueryMiddleware)
type MatchFunc ¶
func MatchCommandRequest ¶
func MatchCommandRequest(req interface{}) MatchFunc
func MatchQueryRequest ¶
func MatchQueryRequest(req interface{}) MatchFunc
type Option ¶
type Option struct { CommandFactory CommandFactory QueryFactory QueryFactory CommandResultFactory CommandResultFactory QueryResultFactory QueryResultFactory }
func CreateOption ¶
func CreateOption(funcs ...OptionFunc) *Option
func DefaultOption ¶
func DefaultOption() *Option
type OptionFunc ¶
type OptionFunc func(*Option)
func WithBaseCommandFactory ¶
func WithBaseCommandFactory() OptionFunc
func WithBaseCommandResultFactory ¶
func WithBaseCommandResultFactory() OptionFunc
func WithBaseQueryFactory ¶
func WithBaseQueryFactory() OptionFunc
func WithBaseQueryResultFactory ¶
func WithBaseQueryResultFactory() OptionFunc
func WithCommandFactory ¶
func WithCommandFactory(factory CommandFactory) OptionFunc
func WithQueryFactory ¶
func WithQueryFactory(factory QueryFactory) OptionFunc
type Query ¶
type Query interface { ID() QueryID Request() QueryRequest }
type QueryFactory ¶
type QueryFactory func(QueryRequest) (Query, error)
type QueryHandler ¶
type QueryHandlerFunc ¶
type QueryMiddleware ¶
type QueryMiddleware func(next QueryHandler) QueryHandler
type QueryRequest ¶
type QueryRequest interface{}
type QueryResult ¶
type QueryResult interface { Query() Query Data() interface{} }
type QueryResultFactory ¶
type QueryResultFactory func(Query, interface{}) (QueryResult, error)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) MatchCommand ¶
func (r *Registry) MatchCommand(cmd Command) (CommandHandler, []CommandMiddleware, error)
func (*Registry) MatchQuery ¶
func (r *Registry) MatchQuery(qry Query) (QueryHandler, []QueryMiddleware, error)
func (*Registry) RegisterCommand ¶
func (r *Registry) RegisterCommand(match MatchFunc, hdlr CommandHandler, mdlwrs ...CommandMiddleware)
func (*Registry) RegisterQuery ¶
func (r *Registry) RegisterQuery(match MatchFunc, hdlr QueryHandler, mdlwrs ...QueryMiddleware)
Click to show internal directories.
Click to hide internal directories.