Documentation ¶
Index ¶
- type Bus
- type BusPublisher
- type BusSubscriber
- type EventBus
- func (bus *EventBus) Publish(topic string, args ...interface{})
- func (bus *EventBus) Subscribe(topic string, fn interface{}) error
- func (bus *EventBus) SubscribeAsync(topic string, fn interface{}, transactional bool) error
- func (bus *EventBus) Unsubscribe(topic string, handler interface{}) error
- func (bus *EventBus) WaitAsync()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus interface { BusSubscriber BusPublisher }
Bus englobes global (subscribe, publish, control) bus behavior
type BusPublisher ¶
type BusPublisher interface {
Publish(topic string, args ...interface{})
}
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 Unsubscribe(topic string, handler interface{}) error WaitAsync() }
BusSubscriber defines subscription-related bus behavior
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus - box for handlers and callbacks.
func (*EventBus) Publish ¶
Publish executes callback defined for a topic. Any additional argument will be transferred to the callback.
func (*EventBus) Subscribe ¶
Subscribe subscribes to a topic. Returns error if `fn` is not a function.
func (*EventBus) SubscribeAsync ¶
SubscribeAsync subscribes to a topic with an asynchronous callback Transactional determines whether subsequent callbacks for a topic are run serially (true) or concurrently (false) Returns error if `fn` is not a function.
func (*EventBus) Unsubscribe ¶
Unsubscribe removes callback defined for a topic. Returns error if there are no callbacks subscribed to the topic.