nats

package module
v0.0.0-...-fc4206c Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package nats provides config and flags for connecting to NATS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Servers      []string
	Name         string
	Username     string
	Password     string
	PasswordFile string
	Store        string
	Credentials  CredsConfig
	TLSConfig    *tls.Config
}

Config is the configuration for the NATS connection.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration for the NATS connection.

func (*Config) Connect

func (c *Config) Connect(ctx context.Context) (*nats.Conn, error)

Connect opens a connection to NATS.

func (*Config) Flags

func (c *Config) Flags(prefix string, defaults *Config) *pflag.FlagSet

Flags returns a flagset that can be added to the command line.

type CredsConfig

type CredsConfig struct {
	CredsFile string
	JWTFile   string
	SeedFile  string
}

CredsConfig represents NATS credentials.

func (CredsConfig) Load

func (f CredsConfig) Load(_ context.Context, fileReader FileReader) (nats.Option, error)

Load loads the NATS credentials. If fileReader is nil, this uses ioutil.ReadFile.

type FileReader

type FileReader interface {
	ReadFile(filename string) ([]byte, error)
}

FileReader reads a file and returns its bytes.

Directories

Path Synopsis
cmd
stickyrouter Module

Jump to

Keyboard shortcuts

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