message-bus

message-bus

  • Docs
  • Help
  • GitHub

›Quick Start

Quick Start

  • Installation
  • Basic example

Use Cases

  • Pub/Sub

Benchmark

  • Benchmark

Basic example

Publish block only when the buffer of one of the subscribers is full. Change the buffer size altering queueSize when creating new message bus.

package main

import (
    "fmt"
    "sync"

    messagebus "github.com/vardius/message-bus"
)

func main() {
    queueSize := 100
    bus := messagebus.New(queueSize)

    var wg sync.WaitGroup
    wg.Add(2)

    _ = bus.Subscribe("topic", func(v bool) {
        defer wg.Done()
        fmt.Println(v)
    })

    _ = bus.Subscribe("topic", func(v bool) {
        defer wg.Done()
        fmt.Println(v)
    })

    bus.Publish("topic", true)
    wg.Wait()
}
← InstallationPub/Sub →
message-bus
Docs
DocumentationGoDoc
Community
Support
More
rafallorenz.comGitHubStar
Copyright © 2021 Rafał Lorenz