Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/steeve/broadcaster
Broadcast (one to many, fanout) messaging with payloads for Go
https://github.com/steeve/broadcaster
Last synced: 2 months ago
JSON representation
Broadcast (one to many, fanout) messaging with payloads for Go
- Host: GitHub
- URL: https://github.com/steeve/broadcaster
- Owner: steeve
- License: apache-2.0
- Created: 2015-05-14T11:43:50.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-14T13:22:33.000Z (over 9 years ago)
- Last Synced: 2024-06-20T11:48:17.615Z (7 months ago)
- Language: Go
- Homepage:
- Size: 137 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# broadcaster
This package implements broadcast type messaging (or event) in a Go idiomatic
way not based on a list of handlers.This is based on the design invented by [Roger Peppe](https://rogpeppe.wordpress.com/2009/12/01/concurrent-idioms-1-broadcasting-values-in-go-with-linked-channels/)
and the actual implementation from the [gibb package](https://github.com/dagoof/gibb),
modified to only expose channels, which are the prefered way of communicating in Go.Contrary to ordinary packages which use a list of channels and register/unregister methods,
this package makes use of a linked list of channels to broadcast values in a
fanout way.## Install
```
$ go get github.com/steeve/broadcaster
```## How to use
```go
package mainimport (
"fmt""github.com/steeve/broadcaster"
)func main() {
b := broadcaster.NewBroadcaster()
defer b.Close()for i := 0; i < 10; i++ {
go func() {
read, done := b.Listen()
defer close(done)fmt.Println(<-read)
}()
}b.Broadcast("sample payload")
}
```