Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultSubscriber ¶
type DefaultSubscriber struct{}
func (DefaultSubscriber) OnMessage ¶
func (DefaultSubscriber) OnMessage(*Message)
func (DefaultSubscriber) OnQuit ¶
func (DefaultSubscriber) OnQuit()
type MessageBus ¶
type MessageBus interface { // A subscriber register on s specific topic. // When a message on this topic is published, the subscriber's OnMessage() is called. Register(topic Topic, sub Subscriber) // Used to publish a message on this message bus to notify subscribers. Publish(topic Topic, payload interface{}) // Used to publish a message on this message bus to notify subscribers. // Safe mode, make sure the subscriber's OnMessage() is called with the order of a message on this topic is published. PublishSafe(topic Topic, payload interface{}) // Close the message bus, all publishes are ignored. Close() }
MessageBus provides a pub-sub interface for cross-module communication
func NewMessageBus ¶
func NewMessageBus() MessageBus
type Subscriber ¶
type Subscriber interface { // When a message with topic A is published on the message bus, // all the subscribers's OnMessage() methods of topic A are called. OnMessage(*Message) // When the message bus is shutting down, OnQuit() }
Subscriber should implement these methods,
Click to show internal directories.
Click to hide internal directories.