Categorygithub.com/go-zoox/pubsub
modulepackage
1.2.3
Repository: https://github.com/go-zoox/pubsub.git
Documentation: pkg.go.dev

# README

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.

# Packages

No description provided by the author

# Functions

New creates a new pubsub.

# Variables

Version is the current version of the package.

# Structs

Config is the config for a pubsub.
Message is a pubsub message.

# Interfaces

PubSub is a simple pubsub.

# Type aliases

Handler is a pubsub handler.