Documentation
¶
Overview ¶
Package event provides an in-process publish/subscribe event bus.
Handlers can be registered synchronously or asynchronously, as one-shot (once) subscriptions, and in a transactional mode that serializes async delivery. It is meant for decoupling components within a single process, not for cross-service messaging (use the kafka package for that).
Index ¶
Constants ¶
View Source
const ( ErrCodeBusNotReflectType = "BUS-001" ErrCodeBusTopicNotExists = "BUS-002" )
Variables ¶
View Source
var ( ErrBusNotReflectType = func(v reflect.Kind) error { return jet.NewAppErrBuilder(ErrCodeBusNotReflectType, "%s is not of type reflect.Func", v).Err() } ErrBusTopicNotExists = func(topic string) error { return jet.NewAppErrBuilder(ErrCodeBusTopicNotExists, "topic doesn't exists (%s)", topic).Err() } )
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus interface {
BusController
BusSubscriber
BusPublisher
}
Bus is a global (subscribe, publish, control) bus behavior
type BusController ¶
BusController defines bus control behavior (checking handler's presence, synchronization)
type BusPublisher ¶
BusPublisher defines publishing-related bus behavior
type BusSubscriber ¶
type BusSubscriber interface {
Subscribe(topic string, fn interface{}) error
SubscribeAsync(topic string, fn interface{}, transactional bool) error
SubscribeOnce(topic string, fn interface{}) error
SubscribeOnceAsync(topic string, fn interface{}) error
Unsubscribe(topic string, handler interface{}) error
}
BusSubscriber defines subscription-related bus behavior
Click to show internal directories.
Click to hide internal directories.