PubSub

This package provides a simple pub/sub implementation using the NATS messaging system. It allows users to subscribe and publish events and messages easily.

Installation

To use this package in your project, add the following import statement:

import "github.com/pingponglabs/mediamagic-platform/libs/pubsub"

Usage

Creating a new PubSub client

import (
	"github.com/nats-io/nats.go"
	"go.uber.org/zap"
)

// ...

conn, _ := nats.Connect(nats.DefaultURL)
logger, _ := zap.NewProduction()
pubsubClient := pubsub.New(conn, logger)

Subscribing to a generic event

Subscribing to a typed event

Publishing a generic event

Publishing a typed event

Last updated