https://github.com/vardius/message-bus
    https://rafallorenz.com/message-bus

    1. package main
    2. import (
    3. "fmt"
    4. "sync"
    5. messagebus "github.com/vardius/message-bus"
    6. )
    7. func main() {
    8. queueSize := 100
    9. bus := messagebus.New(queueSize)
    10. var wg sync.WaitGroup
    11. wg.Add(2)
    12. _ = bus.Subscribe("topic", func(v bool) {
    13. defer wg.Done()
    14. fmt.Println(v)
    15. })
    16. _ = bus.Subscribe("topic", func(v bool) {
    17. defer wg.Done()
    18. fmt.Println(v)
    19. })
    20. bus.Publish("topic", true)
    21. wg.Wait()
    22. }