nats

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package nats hold the implementation of the Publisher and PubSub interfaces for the NATS messaging system, the internal messaging broker of the Magistrala IoT platform. Due to the practical requirements implementation Publisher is created alongside PubSub. The reason for this is that Subscriber implementation of NATS brings the burden of additional struct fields which are not used by Publisher. Subscriber is not implemented separately because PubSub can be used where Subscriber is needed.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotSubscribed = errors.New("not subscribed")
	ErrEmptyTopic    = errors.New("empty topic")
	ErrEmptyID       = errors.New("empty id")
)

Publisher and Subscriber errors.

View Source
var ErrInvalidType = errors.New("invalid type")

ErrInvalidType is returned when the provided value is not of the expected type.

Functions

func JSStream

func JSStream(stream jetstream.JetStream) messaging.Option

JSStream sets the JetStream for the publisher.

func NewPubSub

func NewPubSub(ctx context.Context, url string, logger *slog.Logger, opts ...messaging.Option) (messaging.PubSub, error)

NewPubSub returns NATS message publisher/subscriber. Parameter queue specifies the queue for the Subscribe method. If queue is specified (is not an empty string), Subscribe method will execute NATS QueueSubscribe which is conceptually different from ordinary subscribe. For more information, please take a look here: https://docs.nats.io/developing-with-nats/receiving/queues. If the queue is empty, Subscribe will be used.

func NewPublisher

func NewPublisher(ctx context.Context, url string, opts ...messaging.Option) (messaging.Publisher, error)

NewPublisher returns NATS message Publisher.

func Prefix

func Prefix(prefix string) messaging.Option

Prefix sets the prefix for the publisher.

func Stream

func Stream(stream jetstream.Stream) messaging.Option

Stream sets the Stream for the subscriber.

Types

This section is empty.

Directories

Path Synopsis
Package tracing provides tracing instrumentation for Magistrala things policies service.
Package tracing provides tracing instrumentation for Magistrala things policies service.

Jump to

Keyboard shortcuts

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