Skip to content

dewadg/haro

Repository files navigation

Haro

Topic-based pubsub library.

go report card test Coverage Status Go.Dev reference

Usage

Install with:

go get github.com/dewadg/haro

Declaring topic

intTopic := haro.DeclareTopic[int]()

stringTopic := haro.DeclareTopic[string]()

Registering subscribers

intTopic.Subscribe(func(ctx context.Context, p int) error {
    return nil
})

stringTopic.Subscribe(func(ctx context.Context, p string) error {
    return nil
})

Publishing

var err error

err = intTopic.Publish(context.Background(), 5)

err = stringTopic.Publish(context.Background(), "test")

Limitations

  • It's not a distributed pubsub mechanism, it means pubsub across different instances won't work (eg: across docker container replication)
  • No recovery since it doesn't utilize any external storage, it's purely using Channel to store the published messages