37f444e6523a8c3b181c05ab5a4bd25c0336e3de
GubGub
Yet another in-memory Go PubSub library. I started to develop what is now GubGub in one of my personal projects but I soon found myself using it in other completely unrelated projects and I thought it could be a nice thing to share.
Getting started
go get -u gitlab.com/naterciom/gubgub
Example
package main
import (
"context"
"fmt"
"time"
"gitlab.com/naterciom/gubgub"
)
type MyMessage struct {
Name string
}
func main() {
ctx, cancel := context.WithTimeout(context.TODO(), time.Second)
defer cancel()
topic := gubgub.NewAsyncTopic[MyMessage](ctx)
topic.Subscribe(gubgub.Forever(func(msg MyMessage) {
fmt.Printf("Hello %s", msg.Name)
}))
topic.Publish(MyMessage{Name: "John Smith"})
<-ctx.Done()
}
Languages
Go
100%