nats

package
v0.0.0-...-a66760f Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Publish(subject string, data []byte) error
	Subscribe(subject string, handler func(data []byte)) (*nats.Subscription, error)
	Close()
}

func NewClient

func NewClient(cfg NATSConfig) (Client, error)

NewClient creates and connects a new NATS client.

type ClientImpl

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

func (*ClientImpl) Close

func (n *ClientImpl) Close()

Close cleanly shuts down the NATS connection.

func (*ClientImpl) Publish

func (n *ClientImpl) Publish(subject string, data []byte) error

Publish sends a message to the given subject.

func (*ClientImpl) Subscribe

func (n *ClientImpl) Subscribe(subject string, handler func(data []byte)) (*nats.Subscription, error)

Subscribe listens for messages on a subject and handles them with the given callback.

type NATSConfig

type NATSConfig struct {
	URL     string
	Timeout time.Duration
}

NATSConfig holds config values for the NATS connection.

Jump to

Keyboard shortcuts

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