# README
PubSub - lightweight pub/sub messaging
Installation
To install the package, run:
go get github.com/go-zoox/pubsub
Getting Started
Subscribe
import (
"github.com/go-zoox/pubsub"
)
func main(t *testing.T) {
ps := pubsub.New(&pubsub.Config{
RedisHost: <RedisHost>,
RedisPort: <RedisPort>,
RedisUsername: <RedisUsername>,
RedisPassword: <RedisPassword>,
RedisDB: <RedisDB>,
})
ps.Subscribe(context.TODO(), "default", func(msg *pubsub.Message) error {
logger.Infof("received message: %s", string(msg.Body))
return nil
})
}
Publish
import (
"github.com/go-zoox/pubsub"
)
func main(t *testing.T) {
ps := pubsub.New(&pubsub.Config{
RedisHost: <RedisHost>,
RedisPort: <RedisPort>,
RedisUsername: <RedisUsername>,
RedisPassword: <RedisPassword>,
RedisDB: <RedisDB>,
})
ps.Publish(context.TODO(), &pubsub.Message{
Topic: "default",
Body: []byte("hello world"),
})
}
License
GoZoox is released under the MIT License.
# Packages
No description provided by the author
# Functions
New creates a new pubsub.
# Variables
Version is the current version of the package.
# Interfaces
PubSub is a simple pubsub.
# Type aliases
Handler is a pubsub handler.