Documentation
¶
Index ¶
- type Bus
- type BusController
- type ChainBus
- func (bus *ChainBus) HasCallback(topic string) bool
- func (bus *ChainBus) Publish(topic string, args ...interface{})
- func (bus *ChainBus) Subscribe(topic string, fn interface{}) error
- func (bus *ChainBus) SubscribeAsync(topic string, fn interface{}, transactional bool) error
- func (bus *ChainBus) SubscribeOnce(topic string, fn interface{}) error
- func (bus *ChainBus) SubscribeOnceAsync(topic string, fn interface{}) error
- func (bus *ChainBus) Unsubscribe(topic string, handler interface{}) error
- func (bus *ChainBus) WaitAsync()
- type ChainPuber
- type ChainSuber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus interface { BusController ChainSuber ChainPuber }
Bus englobes global (subscribe, publish, control) bus behavior.
type BusController ¶
BusController defines bus control behavior (checking handler's presence, synchronization).
type ChainBus ¶
type ChainBus struct {
// contains filtered or unexported fields
}
ChainBus - box for handlers and callbacks.
func (*ChainBus) HasCallback ¶
HasCallback returns true if exists any callback subscribed to the topic.
func (*ChainBus) Publish ¶
Publish executes callback defined for a topic. Any additional argument will be transferred to the callback.
func (*ChainBus) Subscribe ¶
Subscribe subscribes to a topic. Returns error if `fn` is not a function.
func (*ChainBus) SubscribeAsync ¶
SubscribeAsync subscribes to a topic with an asynchronous callback Async determines whether subsequent Publish should wait for callback return Transactional determines whether subsequent callbacks for a topic are run serially (true) or concurrently (false) Returns error if `fn` is not a function.
func (*ChainBus) SubscribeOnce ¶
SubscribeOnce subscribes to a topic once. Handler will be removed after executing. Returns error if `fn` is not a function.
func (*ChainBus) SubscribeOnceAsync ¶
SubscribeOnceAsync subscribes to a topic once with an asynchronous callback Async determines whether subsequent Publish should wait for callback return Handler will be removed after executing. Returns error if `fn` is not a function.
func (*ChainBus) Unsubscribe ¶
Unsubscribe removes callback defined for a topic. Returns error if there are no callbacks subscribed to the topic.
type ChainPuber ¶
type ChainPuber interface {
Publish(topic string, args ...interface{})
}
ChainPuber defines publishing-related bus behavior.
type ChainSuber ¶
type ChainSuber interface { Subscribe(topic string, handler interface{}) error SubscribeAsync(topic string, handler interface{}, transactional bool) error SubscribeOnce(topic string, handler interface{}) error SubscribeOnceAsync(topic string, handler interface{}) error Unsubscribe(topic string, handler interface{}) error }
ChainSuber defines subscribing-related bus behavior.