config

package
v0.0.0-...-9edbc40 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// default values by convention
	DefaultType = "json"
	DefaultFile = "config"

	// environment variables
	EnvConsulHostKey = "GOCONF_CONSUL"
	EnvTypeKey       = "GOCONF_TYPE"
	EnvFileNameKey   = "GOCONF_FILENAME"
	EnvPrefixKey     = "GOCONF_ENV_PREFIX"

	SourceEnv    Source = "env"
	SourceFile   Source = "file"
	SourceConsul Source = "consul"
)

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(cfgFile string)

Types

type Config

type Config struct {
	Rest struct {
		Port              int  `mapstructure:"port"`
		BodyLimit         int  `mapstructure:"body_limit"`
		ReduceMemoryUsage bool `mapstructure:"reduce_memory_usage"`
		ReadTimeOut       int  `mapstructure:"read_timeout"`
		WriteTimeOut      int  `mapstructure:"write_timeout"`
	} `mapstructure:"rest"`
	Logger struct {
		Level string `mapstructure:"level"`
	} `mapstructure:"logger"`
	Database struct {
		Postgres struct {
			Host     string `mapstructure:"host"`
			Port     int    `mapstructure:"port"`
			Username string `mapstructure:"username"`
			Password string `mapstructure:"password"`
			Database string `mapstructure:"database"`
		} `mapstructure:"postgresdb"`
		Maria struct {
			Dsn string `mapstructure:"dsn"`
		} `mapstructure:"mariadb"`
		Mongo struct {
			URI               string `mapstructure:"uri"`
			Db                string `mapstructure:"db"`
			ConnectionTimeOut int64  `mapstructure:"connection_timeout"`
			PingTimeOut       int64  `mapstructure:"ping_timeout"`
		} `mapstructure:"mongodb"`
	} `mapstructure:"database"`
	TracerConfig TracerConfig `mapstructure:"tracer_config"`
}
var (
	GlobalCfg Config
)

func GetConfig

func GetConfig() Config

func NewConfig

func NewConfig() (cfg Config)

type Source

type Source string

type TracerConfig

type TracerConfig struct {
	Tracer             string  `mapstructure:"tracer" json:"tracer"`
	JaegerCollectorURL string  `mapstructure:"jaeger_url" json:"jaeger_url"`
	JaegerMode         string  `mapstructure:"jaeger_mode" json:"jaeger_mode"`
	SamplingRate       float32 `mapstructure:"tracer_sample_rate" json:"tracer_sample_rate"`
}

Jump to

Keyboard shortcuts

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