nats

package
v0.0.0-...-626d6d5 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNATS       = fmt.Errorf("nats error")
	ErrDispatcher = fmt.Errorf("%w: dispatcher", ErrNATS)
	ErrPayloadLim = fmt.Errorf("%w: payload oversized limit", ErrNATS)
)

Functions

func Publish

func Publish(subj string, data []byte, headers ...string) error

Publish adds payload in queue with optional key-value headers

func StartDispatcher

func StartDispatcher(options []DurableCfg) error

StartDispatcher connects to stan and adds durable subscriptions

func StartServer

func StartServer(config Config) error

StartServer runs NATS

func StopDispatcher

func StopDispatcher() error

StopDispatcher ends dispatching

func StopServer

func StopServer()

StopServer shutdowns NATS

Types

type Config

type Config struct {
	AckWait            time.Duration
	LogColors          bool
	MaxInflight        int
	MaxPubAcksInflight int
	MaxPayload         int32
	MonitorPort        int
	StoreDir           string
	StoreType          string
	StoreMaxAge        time.Duration
	StoreMaxBytes      int64
	StoreMaxMsgs       int64

	ConfigFile string
}

Config defines NATS configurable options

type DurableCfg

type DurableCfg struct {
	Durable string
	Subject string
	Handler func(msg NatsMsg) error
}

DurableCfg defines subscription

type NatsMsg

type NatsMsg struct {
	*nats.Msg
}

Jump to

Keyboard shortcuts

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