bus

package
v5.3.0-beta1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHandlerNotFound = errors.New("handler not found")

Functions

func AddEventListener

func AddEventListener(handler HandlerFunc)

Package level functions

func AddHandler

func AddHandler(implName string, handler HandlerFunc)

Package level functions

func AddHandlerCtx

func AddHandlerCtx(implName string, handler HandlerFunc)

Package level functions

func AddWildcardListener

func AddWildcardListener(handler HandlerFunc)

func ClearBusHandlers

func ClearBusHandlers()

func Dispatch

func Dispatch(msg Msg) error

func DispatchCtx

func DispatchCtx(ctx context.Context, msg Msg) error

func InTransaction

func InTransaction(ctx context.Context, fn func(ctx context.Context) error) 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.

func Publish

func Publish(msg Msg) 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)
	AddWildcardListener(handler HandlerFunc)

	// SetTransactionManager allows the user to replace the internal
	// noop TransactionManager that is responsible for manageing
	// transactions in `InTransaction`
	SetTransactionManager(tm TransactionManager)
}

func GetBus

func GetBus() Bus

Want to get rid of global bus

func New

func New() Bus

type CtxHandlerFunc

type CtxHandlerFunc func()

type HandlerFunc

type HandlerFunc interface{}

type InProcBus

type InProcBus struct {
	// contains filtered or unexported fields
}

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) AddWildcardListener

func (b *InProcBus) AddWildcardListener(handler HandlerFunc)

func (*InProcBus) Dispatch

func (b *InProcBus) Dispatch(msg Msg) error

func (*InProcBus) DispatchCtx

func (b *InProcBus) DispatchCtx(ctx context.Context, msg Msg) error

func (*InProcBus) InTransaction

func (b *InProcBus) InTransaction(ctx context.Context, fn func(ctx context.Context) error) error

func (*InProcBus) Publish

func (b *InProcBus) Publish(msg Msg) error

func (*InProcBus) SetTransactionManager

func (b *InProcBus) SetTransactionManager(tm TransactionManager)

type Msg

type Msg interface{}

type TransactionManager

type TransactionManager interface {
	InTransaction(ctx context.Context, fn func(ctx context.Context) error) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL