/ChannelBroker

Primary LanguageGoMIT LicenseMIT

tests Go version GoDoc reference

Channel Broker

A helper for golang that provides a broker based on channels. So you send to one channel receive by multiple channels. Receving channels can be created and removed at runtime.

Usage Example

package main

import (
    "fmt"
    "github.com/JulianJacobi/ChannelBroker"
)

func main() {
    b := broker.New[string]()

    c1 := b.NewChannel()
    c2 := b.NewChannel()

    b.Chan <- "Test"

    r1 := <-c1.Chan
    fmt.Println(r1)

    r2 := <-c2.Chan
    fmt.Println(r2)
}