pubsub

package
v0.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package pubsub provides the nats client to connect and consume subscriptions messages

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMsgHandlerNotRegistered is returned when the message handler callback is not registered
	ErrMsgHandlerNotRegistered = errors.New("nats message handler callback is not registered")
)

Functions

This section is empty.

Types

type MsgHandler

type MsgHandler func(msg events.Message[events.ChangeMessage]) error

MsgHandler is a callback function that processes messages delivered to subscribers

type Subscriber

type Subscriber struct {
	// contains filtered or unexported fields
}

Subscriber is the subscriber client

func NewSubscriber

func NewSubscriber(ctx context.Context, connection events.Connection, opts ...SubscriberOption) *Subscriber

NewSubscriber creates a new Subscriber

func (Subscriber) Listen

func (s Subscriber) Listen() error

Listen start listening for messages on registered subjects and calls the registered message handler

func (*Subscriber) Subscribe

func (s *Subscriber) Subscribe(topic string) error

Subscribe subscribes to a nats subject

type SubscriberOption

type SubscriberOption func(s *Subscriber)

SubscriberOption is a functional option for the Subscriber

func WithLogger

func WithLogger(l *zap.SugaredLogger) SubscriberOption

WithLogger sets the logger for the Subscriber

func WithMaxMsgProcessAttempts added in v0.0.8

func WithMaxMsgProcessAttempts(max uint64) SubscriberOption

WithMaxMsgProcessAttempts sets the maximum number of times a message will attempt to process before being terminated

func WithMsgHandler

func WithMsgHandler(cb MsgHandler) SubscriberOption

WithMsgHandler sets the message handler callback for the Subscriber

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL