Documentation
¶
Overview ¶
Package messagebus provides simple async message publisher
Example ¶
bus := messagebus.New(runtime.NumCPU())
var wg sync.WaitGroup
wg.Add(2)
bus.Subscribe("topic", func(v bool) {
defer wg.Done()
fmt.Println("s1", v)
})
bus.Subscribe("topic", func(v bool) {
defer wg.Done()
fmt.Println("s2", v)
})
bus.Publish("topic", true)
wg.Wait()
Output: s1 true s2 true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageBus ¶
type MessageBus interface {
Publish(topic string, args ...interface{})
Subscribe(topic string, fn interface{}) error
Unsubscribe(topic string, fn interface{}) error
}
MessageBus implements publish/subscribe messaging paradigm
func New ¶
func New(maxConcurrentCalls int) MessageBus
New creates new MessageBus maxConcurrentCalls limits concurrency by using a buffered channel semaphore
Click to show internal directories.
Click to hide internal directories.