nats

package
v0.98.10 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubSub

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

PubSub implements msgqueue.PubSub over core NATS. Subjects are subjectPrefix + "." + topic.Name() (default prefix "hatchet.pubsub"), delivery is best-effort at-most-once.

func NewPubSub

func NewPubSub(fs ...PubSubOpt) (func() error, *PubSub, error)

NewPubSub connects synchronously to NATS and returns a PubSub. Fails if the server is unreachable or if its max_payload is below msgqueue.MaxMessageSize.

func (*PubSub) IsReady

func (p *PubSub) IsReady() bool

func (*PubSub) Pub

func (p *PubSub) Pub(ctx context.Context, topic msgqueue.Topic, msg *msgqueue.Message) error

Pub publishes a message to the topic. Oversized multi-payload messages are chunked like rabbitmq/pubsub.go.

func (*PubSub) Sub

func (p *PubSub) Sub(topic msgqueue.Topic, handler msgqueue.MsgHandler) (func() error, error)

Sub subscribes to a topic with plain Subscribe (fan-out to every subscriber). Delivery is at-most-once: handler errors are logged, never redelivered.

type PubSubOpt

type PubSubOpt func(*PubSubOpts)

func WithPubSubLogger

func WithPubSubLogger(l *zerolog.Logger) PubSubOpt

func WithPubSubPassword

func WithPubSubPassword(password string) PubSubOpt

WithPubSubPassword sets the NATS password for nats.UserInfo.

func WithPubSubSubjectPrefix

func WithPubSubSubjectPrefix(prefix string) PubSubOpt

WithPubSubSubjectPrefix sets the NATS subject prefix (default "hatchet.pubsub"). Empty falls back to the default. No trimming or validation: a bad prefix fails loudly via nats ErrBadSubject at startup.

func WithPubSubURL

func WithPubSubURL(url string) PubSubOpt

WithPubSubURL sets the NATS seed URL(s). Comma-separated lists are passed through to nats.go. Prefer bare hosts and set Username/Password so rediscovered cluster peers authenticate.

func WithPubSubUsername

func WithPubSubUsername(username string) PubSubOpt

WithPubSubUsername sets the NATS username for nats.UserInfo.

type PubSubOpts

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

Jump to

Keyboard shortcuts

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