Skip to content

go-zoox/mq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MQ - lightweight message queue

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

Installation

To install the package, run:

go get github.com/go-zoox/mq

Getting Started

Consumer

import (
  "github.com/go-zoox/mq"
)

func main(t *testing.T) {
	m := mq.New(&mq.Config{
		RedisHost:     <RedisHost>,
		RedisPort:     <RedisPort>,
		RedisUsername: <RedisUsername>,
		RedisPassword: <RedisPassword>,
		RedisDB:       <RedisDB>,
	})

	m.Consume(context.TODO(), "default", func(msg *mq.Message) error {
		logger.Infof("received message: %s", string(msg.Body))
		return nil
	})
}

Producer

import (
  "github.com/go-zoox/mq"
)

func main(t *testing.T) {
	m := mq.New(&mq.Config{
		RedisHost:     <RedisHost>,
		RedisPort:     <RedisPort>,
		RedisUsername: <RedisUsername>,
		RedisPassword: <RedisPassword>,
		RedisDB:       <RedisDB>,
	})

	m.Send(context.TODO(), &mq.Message{
		Topic: "default",
		Body:  []byte("hello world"),
	})
}

License

GoZoox is released under the MIT License.