config

package
v0.0.0-...-8d2e23b Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultWebAddress is the default address the service look for the database
	DefaultDBHost = "localhost"

	// DefaultDBPort is the default port the service connect to the database
	DefaultDBPort = 5432

	// DefaultDBUser is the default user the service will try for the database
	DefaultDBUser = "postgres"

	// DefaultDBPassword is the default password the service will try for the database
	DefaultDBPassword = "postgres"

	// DefaultDBName is the default dbname the service connect to the database
	DefaultDBName = "caputo"
)

db defaults

View Source
const (
	// DefaultWebAddress is the default address the service will bind to
	DefaultWebAddress = "0.0.0.0"

	// DefaultWebPort is the default port the service will listen on
	DefaultWebPort = 8080
)

web defaults

View Source
const (
	DefaultStoragePath = "uploaded"
)

storage defaults

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Web is the configuration for the web listener
	Web *WebConfig `yaml:"web"`

	// DB is the configuration for the db connection
	DB *DBConfig `yaml:"db"`

	// Storage is the configuration for file storage
	Storage *StorageConfig `yaml:"storage"`

	// Meta contains meta information about the config
	// it isn't specified in the user config
	Meta *MetaConfig
}

Config is the main configuration structure

func Load

func Load(commitHash, buildDate, configFile string) (*Config, error)

Load loads a custom configuration file

type DBConfig

type DBConfig struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Name     string `yaml:"dbname"`
}

DBConfig is the structure which supports the configuration of the database

func (*DBConfig) DSN

func (db *DBConfig) DSN() string

type MetaConfig

type MetaConfig struct {
	CommitHash string
	BuildDate  string
	// contains filtered or unexported fields
}

MetaConfig is the automatically filled meta information about the config

type StorageConfig

type StorageConfig struct {
	Path string `yaml:"path"`
}

type WebConfig

type WebConfig struct {
	// Address to listen on (defaults to 0.0.0.0 specified by DefaultWebAddress)
	Address string `yaml:"address"`

	// Port to listen on (default to 8080 specified by DefaultWebPort)
	Port int `yaml:"port"`
}

WebConfig is the structure which supports the configuration of the endpoint which provides access to the web frontend

func (*WebConfig) SocketAddress

func (web *WebConfig) SocketAddress() string

SocketAddress returns the combination of the Address and the Port

Jump to

Keyboard shortcuts

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