To install the package, run:
go get github.com/go-zoox/pubsub
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
})
}
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"),
})
}
GoZoox is released under the MIT License.