Skip to content

go-zoox/pubsub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PubSub - lightweight pub/sub messaging

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

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.

About

Lightweight pub/sub messaging

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages