config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIsADirectory = errors.New("is a directory, not a normal file")

Functions

func ParseFlags

func ParseFlags() (string, error)

ParseFlags will create and parse the CLI flags and return the path to be used elsewhere.

func ValidateConfigPath

func ValidateConfigPath(path string) error

ValidateConfigPath just makes sure, that the path provided is a file, that can be read.

Types

type Config

type Config struct {
	Server struct {
		// Host is the local machine IP Address to bind the HTTP Server to
		Host string `yaml:"host"`

		// Port is the local machine TCP Port to bind the HTTP Server to
		Port string `yaml:"port"`

		Timeout struct {
			// Server is the general server timeout to use
			// for graceful shutdowns
			Server time.Duration `yaml:"server"`

			// Write is the amount of time to wait until an HTTP server
			// write operation is cancelled
			Write time.Duration `yaml:"write"`

			// Read is the amount of time to wait until an HTTP server
			// read operation is cancelled
			Read time.Duration `yaml:"read"`

			// Read is the amount of time to wait
			// until an IDLE HTTP session is closed
			Idle time.Duration `yaml:"idle"`

			// Request is the amount of time to wait
			// until a request is aborted if the context is blocking
			Request time.Duration `yaml:"request"`
		} `yaml:"timeout"`

		// MaxRequestBodySize can be specified as `4x` or `4xB`, where x is one of the multiple from K, M,
		// G, T or P.
		MaxRequestBodySize string `yaml:"maxRequestBodySize"`

		CORS struct {
			AllowOrigins []string `yaml:"allowOrigins"`
			AllowHeaders []string `yaml:"allowHeaders"`
		} `yaml:"cors"`
	} `yaml:"server"`

	Redis struct {
		redis.UniversalOptions `yaml:",inline"`
		Ping                   struct {
			Enable   bool          `yaml:"enable"`
			Timeout  time.Duration `yaml:"timeout"`
			Interval time.Duration `yaml:"interval"`
		} `yaml:"ping"`

		Module struct {
			Expiration time.Duration `yaml:"expiration"`
		}
	} `yaml:"redis"`

	LogSettings `yaml:"log"`
	Logger      *zerolog.Logger `yaml:"-"`

	password.PasswordGenerator `yaml:"-"`
	service.UsernameGenerator  `yaml:"-"`

	Services struct {
		service.Accounts
		service.Sharing
		service.Modules
		service.Devices
		service.Health
		service.MetadataProvider
	} `yaml:"-"`
}

Config struct for webapp config.

func NewConfig

func NewConfig(configPath string) (*Config, error)

NewConfig returns a new decoded Config struct.

type LogSettings

type LogSettings struct {
	Format LogSettingsFormat `yaml:"format"`
}

type LogSettingsFormat

type LogSettingsFormat string
const (
	LogSettingsFormatJSON   LogSettingsFormat = "json"
	LogSettingsFormatPretty LogSettingsFormat = "pretty"
	LogSettingsFormatNone   LogSettingsFormat = ""
)

Jump to

Keyboard shortcuts

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