nats

package
v0.0.0-...-132c30d Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package nats exposes an embedded NATS server.

It allows for message-oriented communication between the instances of this app.

Index

Constants

This section is empty.

Variables

View Source
var DefaultSettings = Settings{
	URL: "nats://localhost:4222",
	Topics: TopicsSettings{
		Postings: "postings",
		Results:  "results",
	},
	Server: ServerSettings{
		MaxReconnect:           nats.DefaultOptions.MaxReconnect,
		ReconnectWait:          nats.DefaultOptions.ReconnectWait,
		StartupTimeout:         3 * time.Second,
		ClusterID:              "messaging",
		ClusterURL:             "nats://localhost:5333",
		ClusterRoutes:          "",
		ClusterHeadlessService: "",
		MonitorHTTPPort:        6333,
	},
}

DefaultSettings define defaults for the embedded NATS server and clients.

Functions

func DefaultSettingsNATS

func DefaultSettingsNATS() *viper.Viper

DefaultSettingsNATS returns all defaults for this package as a viper register.

This is primarily intended for documentation & help purpose.

func SpanContextFromHeaders

func SpanContextFromHeaders(parentCtx context.Context, msg *nats.Msg) context.Context

SpanContextFromHeaders extracts a trace span from the headers of a NATS message.

Types

type Server

type Server struct {
	Settings
	// contains filtered or unexported fields
}

func New

func New(rt injected.Runtime) *Server

func (*Server) Start

func (s *Server) Start() error

Start an embedded NATS server in the background.

func (*Server) Stop

func (s *Server) Stop() error

type ServerDebugSettings

type ServerDebugSettings struct {
	Logs  bool
	Debug bool
	Trace bool
}

type ServerSettings

type ServerSettings struct {
	StartupTimeout         time.Duration
	ReconnectWait          time.Duration
	MaxReconnect           int
	ClusterID              string
	ClusterURL             string
	ClusterRoutes          string
	ClusterHeadlessService string
	MonitorHTTPPort        int // port for monitoring the health status of the server
	Debug                  ServerDebugSettings
}

type Settings

type Settings struct {
	URL    string
	Topics TopicsSettings
	Server ServerSettings
}

Settings for embedded NATS.

Primarily intended for being unmarshaled from a viper config.

func MakeSettings

func MakeSettings(cfg *viper.Viper) (Settings, error)

type TopicsSettings

type TopicsSettings struct {
	Postings string
	Results  string
}

Jump to

Keyboard shortcuts

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