Versions in this module Expand all Collapse all v0 v0.2.0 Jul 6, 2021 Changes in this version + var ErrInvalidQueryResult = errors.New("Query result must be a pointer") + func CommandHandlerName(h CommandHandler) string + func Get(ctx context.Context, key string) interface + func QueryHandlerName(h QueryHandler) string + type Bus struct + Container di.Container + var Instance *Bus + func NewBus(ctx context.Context, bcs []Module, configs ...Config) *Bus + func (b *Bus) Close() + func (b *Bus) Dispatch(ctx context.Context, cmd Command, sync bool) (*CommandResponse, error) + func (b *Bus) ExtendCommands(fn func(CmdBuilder)) + func (b *Bus) ExtendEvents(rules ...EventRules) *Bus + func (b *Bus) ExtendQueries(fn func(QueryBuilder)) + func (b *Bus) Get(key string) interface{} + func (b *Bus) Publish(ctx context.Context, events ...Event) error + func (b *Bus) Query(ctx context.Context, query Query, result interface{}) error + func (b *Bus) RegisterContextKey(key interface{ ... }, fn func(j []byte) interface{}) + func (b *Bus) RegisterDeletion(fn func()) + func (b *Bus) RegisterWork(fn func()) + func (b *Bus) Use(ms ...interface{}) + func (b *Bus) Work() + type CmdBuilder interface + Group func(func(CmdBuilder)) + Use func(middlewares ...CommandMiddleware) + With func(middlewares ...CommandMiddleware) CmdReceiver + type CmdReceiver interface + Command func(Command) commandRecord + type Command interface + Auth func(context.Context) [][]string + Command func() string + Valid func() error + func CommandValidationGuard(ctx context.Context, c Command) (context.Context, Command, error) + type CommandContext struct + func NewCommandContext() *CommandContext + func (c *CommandContext) Command(cmd Command) commandRecord + func (c *CommandContext) Group(fn func(CmdBuilder)) + func (c *CommandContext) Use(middlewares ...CommandMiddleware) + func (c *CommandContext) With(middlewares ...CommandMiddleware) CmdReceiver + func (c CommandContext) Route(cmd Command) (CommandRoute, bool) + func (c CommandContext) Routes() commandRouting + func (c CommandContext) SelfTest() error + type CommandGuard = func(context.Context, Command) (context.Context, Command, error) + type CommandHandler interface + Execute func(context.Context, Command) (CommandResponse, []message.Message) + func CmdMiddlewareFunc(fn func(context.Context, Command) (CommandResponse, []message.Message)) CommandHandler + func CommandLoggingMiddleware(next CommandHandler) CommandHandler + type CommandMiddleware = func(CommandHandler) CommandHandler + type CommandResponse struct + Error error + ID string + type CommandRoute struct + Command Command + Handler CommandHandler + Middleware []CommandMiddleware + type CommandType struct + func (c CommandType) Auth(ctx context.Context) [][]string + func (c CommandType) MessageType() message.Type + type Config = func(*Bus) error + func UseQueue(q Queue) Config + type Def struct + Build func(ctn di.Container) (interface{}, error) + Close func(obj interface{}) error + Name interface{} + Scope string + Tags []di.Tag + Unshared bool + type Event interface + Event func() string + OwnedBy func(interface{ ... }) + type EventHandler interface + Async func() bool + Handle func(context.Context, Event) ([]message.Message, error) + type EventQueue struct + GobEncode bool + func NewEventQueue(owner interface{ ... }) EventQueue + func (e *EventQueue) Publish(events ...Event) + func (e *EventQueue) Release() []Event + type EventRules map[Event][]string + type EventType struct + Owner string + func (e *EventType) OwnedBy(id interface{ ... }) + func (e EventType) MessageType() message.Type + type FuncModule struct + CommandsFunc func(CmdBuilder) + Defs []Def + EventsFunc func() EventRules + QueriesFunc func(QueryBuilder) + ServicesFunc func() []Def + func (m FuncModule) Commands(b CmdBuilder) + func (m FuncModule) EventRules() EventRules + func (m FuncModule) Queries(b QueryBuilder) + func (m FuncModule) Services() []Def + type MessageRouter struct + Events eventRules + func NewMessageRouter() MessageRouter + func (r *MessageRouter) Extend(rules EventRules) + func (r *MessageRouter) ExtendCommands(fn func(b CmdBuilder)) + func (r *MessageRouter) ExtendQueries(fn func(b QueryBuilder)) + func (r MessageRouter) RouteCommand(cmd Command) (CommandRoute, bool) + func (r MessageRouter) RouteEvent(e Event) []string + func (r MessageRouter) RouteQuery(q Query) (QueryRoute, bool) + type Module interface + Commands func(CmdBuilder) + EventRules func() EventRules + Queries func(QueryBuilder) + Services func() []Def + type NoCommandHandler struct + Cmd Command + func (e NoCommandHandler) Error() string + type NoQueryHandler struct + Query Query + func (e NoQueryHandler) Error() string + type Query interface + Auth func(context.Context) [][]string + Query func() string + Valid func() error + func QueryValidationGuard(ctx context.Context, q Query) (context.Context, Query, error) + type QueryBuilder interface + Group func(func(QueryBuilder)) + Use func(middlewares ...QueryMiddleware) + With func(middlewares ...QueryMiddleware) QueryReceiver + type QueryContext struct + func NewQueryContext() *QueryContext + func (c *QueryContext) Group(fn func(QueryBuilder)) + func (c *QueryContext) Query(q Query) queryRecord + func (c *QueryContext) Use(middlewares ...QueryMiddleware) + func (c *QueryContext) With(middlewares ...QueryMiddleware) QueryReceiver + func (c QueryContext) Route(q Query) (QueryRoute, bool) + func (c QueryContext) Routes() queryRouting + func (c QueryContext) SelfTest() error + type QueryGuard = func(context.Context, Query) (context.Context, Query, error) + type QueryHandler interface + Execute func(context.Context, Query, interface{}) error + func QueryLoggingMiddleware(next QueryHandler) QueryHandler + func QueryMiddlewareFunc(fn func(context.Context, Query, interface{}) error) QueryHandler + type QueryMiddleware = func(QueryHandler) QueryHandler + type QueryReceiver interface + Query func(Query) queryRecord + type QueryRoute struct + Handler QueryHandler + Middleware []QueryMiddleware + Query Query + type QueryRoutes map[string]*queryRoutingRecord + type QueryType struct + func (QueryType) Auth(context.Context) [][]string + func (QueryType) MessageType() message.Type + type Queue interface + Close func() + Publish func(context.Context, ...message.Message) error + RegisterCtxKey func(key interface{ ... }, fn func([]byte) interface{}) + Subscribe func(context.Context, func(context.Context, message.Message) error)