natsconfig

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: 7 Imported by: 1

Documentation

Overview

Package natsconfig 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 AuthConfig

type AuthConfig struct {
	Username        string `json:"username,omitempty" yaml:"username,omitempty"`
	Password        string `json:"password,omitempty" yaml:"password,omitempty"`
	PasswordFile    string `json:"passwordFile,omitempty" yaml:"passwordFile,omitempty"`
	CredentialsFile string `json:"credentialsFile,omitempty" yaml:"credentialsFile,omitempty"`
	JWTFile         string `json:"jwtFile,omitempty" yaml:"jwtFile,omitempty"`
	SeedFile        string `json:"seedFile,omitempty" yaml:"seedFile,omitempty"`
}

AuthConfig represents NATS authentication configuration.

func DefaultAuthConfig

func DefaultAuthConfig() *AuthConfig

DefaultAuthConfig returns the default configuration for NATS authentication.

func (*AuthConfig) Flags

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

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

func (*AuthConfig) Load

func (c *AuthConfig) Load(_ context.Context) (nats.Option, error)

Load loads the NATS credentials.

type Config

type Config struct {
	Servers   []string    `json:"servers,omitempty" yaml:"servers,omitempty"`
	Name      string      `json:"name,omitempty" yaml:"name,omitempty"`
	Auth      AuthConfig  `json:"auth,omitempty" yaml:"auth,omitempty"`
	TLSConfig *tls.Config `json:"-" yaml:"-"`
}

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 connects to NATS using this configuration.

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.

Jump to

Keyboard shortcuts

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