Documentation ¶
Index ¶
- Variables
- func AddEventListener(handler HandlerFunc)
- func AddHandler(implName string, handler HandlerFunc)
- func AddHandlerCtx(implName string, handler HandlerFunc)
- func ClearBusHandlers()
- func Dispatch(msg Msg) error
- func DispatchCtx(ctx context.Context, msg Msg) error
- func InTransaction(ctx context.Context, fn func(ctx context.Context) error) error
- func Publish(msg Msg) error
- type Bus
- type CtxHandlerFunc
- type HandlerFunc
- type InProcBus
- func (b *InProcBus) AddEventListener(handler HandlerFunc)
- func (b *InProcBus) AddHandler(handler HandlerFunc)
- func (b *InProcBus) AddHandlerCtx(handler HandlerFunc)
- func (b *InProcBus) Dispatch(msg Msg) error
- func (b *InProcBus) DispatchCtx(ctx context.Context, msg Msg) error
- func (b *InProcBus) InTransaction(ctx context.Context, fn func(ctx context.Context) error) error
- func (b *InProcBus) Publish(msg Msg) error
- func (b *InProcBus) SetTransactionManager(tm TransactionManager)
- type Msg
- type TransactionManager
Constants ¶
This section is empty.
Variables ¶
var ErrHandlerNotFound = errors.New("handler not found")
ErrHandlerNotFound defines an error if a handler is not found
Functions ¶
func AddEventListener ¶
func AddEventListener(handler HandlerFunc)
AddEventListener attaches a handler function to the event listener. Package level function.
func AddHandler ¶
func AddHandler(implName string, handler HandlerFunc)
AddHandler attaches a handler function to the global bus. Package level function.
func AddHandlerCtx ¶
func AddHandlerCtx(implName string, handler HandlerFunc)
AddHandlerCtx attaches a handler function to the global bus context. Package level function.
func ClearBusHandlers ¶
func ClearBusHandlers()
func InTransaction ¶
InTransaction starts a transaction and store it in the context. The caller can then pass a function with multiple DispatchCtx calls that all will be executed in the same transaction. InTransaction will rollback if the callback returns an error.
Types ¶
type Bus ¶
type Bus interface { Dispatch(msg Msg) error DispatchCtx(ctx context.Context, msg Msg) error Publish(msg Msg) error // InTransaction starts a transaction and store it in the context. // The caller can then pass a function with multiple DispatchCtx calls that // all will be executed in the same transaction. InTransaction will rollback if the // callback returns an error. InTransaction(ctx context.Context, fn func(ctx context.Context) error) error AddHandler(handler HandlerFunc) AddHandlerCtx(handler HandlerFunc) AddEventListener(handler HandlerFunc) // SetTransactionManager allows the user to replace the internal // noop TransactionManager that is responsible for managing // transactions in `InTransaction` SetTransactionManager(tm TransactionManager) }
Bus type defines the bus interface structure
type InProcBus ¶
type InProcBus struct {
// contains filtered or unexported fields
}
InProcBus defines the bus structure
func (*InProcBus) AddEventListener ¶
func (b *InProcBus) AddEventListener(handler HandlerFunc)
func (*InProcBus) AddHandler ¶
func (b *InProcBus) AddHandler(handler HandlerFunc)
func (*InProcBus) AddHandlerCtx ¶
func (b *InProcBus) AddHandlerCtx(handler HandlerFunc)
func (*InProcBus) DispatchCtx ¶
DispatchCtx function dispatch a message to the bus context.
func (*InProcBus) InTransaction ¶
InTransaction defines an in transaction function
func (*InProcBus) SetTransactionManager ¶
func (b *InProcBus) SetTransactionManager(tm TransactionManager)
SetTransactionManager function assign a transaction manager to the bus.