conf

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfigFromFile

func LoadConfigFromFile(configFile string, configStruct interface{}, strict bool) error

LoadConfigFromFile - given a struct, load a config from a file and fill in the struct If strict is true, all of the fields in the config struct must be in the file otherwise, the fields in the config struct will act as defaults if the file doesn't contain them Strict will also force an error if the struct contains any fields which are not settable with reflection

func LoadConfigFromMap

func LoadConfigFromMap(m map[string]interface{}, configStruct interface{}, strict bool) error

LoadConfigFromMap load a config struct from a map, this is useful if the type of a config isn't known at load time.

func LoadConfigFromString

func LoadConfigFromString(configString string, configStruct interface{}, strict bool) error

LoadConfigFromString - like LoadConfigFromFile but uses a string

func ValidateDirPath

func ValidateDirPath(path string) (string, error)

ValidateDirPath checks that the provided path exists and is a dir

func ValidateFilePath

func ValidateFilePath(path string) (string, error)

ValidateFilePath checks that the provided path exists and is not a dir

Types

type AccountServerConfig

type AccountServerConfig struct {
	Logging LogConfig
	NATS    NATSConfig
	HTTP    HTTPConfig
	Store   StoreConfig

	OperatorJWTPath      string
	SystemAccountJWTPath string
	SignRequestSubject   string
	SignRequestTimeout   int //milliseconds

	// Below options are only to copy jwt from an old account server for initialization
	Primary            string
	ReplicationTimeout int //milliseconds
	MaxReplicationPack int // maximum number of JWTS to grab on startup
}

AccountServerConfig is the root structure for an account server configuration file.

func DefaultServerConfig

func DefaultServerConfig() *AccountServerConfig

DefaultServerConfig generates a default configuration with logging set to colors, time, debug and trace

type HTTPConfig

type HTTPConfig struct {
	Host         string
	Port         int
	TLS          TLSConf
	ReadTimeout  int //milliseconds
	WriteTimeout int //milliseconds
}

HTTPConfig is used to specify the host/port/tls for an HTTP server

type LogConfig added in v1.0.0

type LogConfig struct {
	Time   bool
	Debug  bool
	Trace  bool
	Colors bool
	PID    bool
	Custom natsserver.Logger
}

LogConfig allows configuration of the logging details

type NATSConfig

type NATSConfig struct {
	Servers []string

	ConnectTimeout int //milliseconds
	ReconnectWait  int //milliseconds
	MaxReconnects  int

	TLS             TLSConf
	UserCredentials string
}

NATSConfig configuration for a NATS connection

type StoreConfig

type StoreConfig struct {
	Dir             string // the path to a folder for mutable storage
	Shard           bool   // optional setting to shard the directory store, avoiding too many files in one folder
	CleanupInterval int    // interval at which expiration is checked

	NSC      string // removed support for this, keep so that we can warn when used
	ReadOnly bool   // removed support for this, keep so that we can warn when used
}

StoreConfig is a catch-all for the store options, the store created depends on the contents of the config: if NSC is set the read-only NSC store is used if Dir is set a folder store is used, mutability is based on ReadOnly otherwise a memory store is used, mutability is based on ReadOnly (which means the r/o store will be stuck empty)

type TLSConf

type TLSConf struct {
	Key  string
	Cert string
	Root string
}

TLSConf holds the configuration for a TLS connection/server

Jump to

Keyboard shortcuts

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