config

package
v0.0.0-...-48e1cf4 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Rds map[string]*redis.Client = map[string]*redis.Client{}

Functions

func GetRdsClientByName

func GetRdsClientByName(name string) (rds *redis.Client, err error)

func LoadConfig

func LoadConfig() (err error)

Types

type ConfigAPI

type ConfigAPI struct {
	//ServiceBatchSize is the number of tasks that a service can read from redis at the same time
	ServiceBatchSize int64 `env:"ServiceBatchSize,default=64"`
}

type ConfigData

type ConfigData struct {
	//AutoAuth should never be true in production
	AutoAuth bool `env:"AutoAuth,default=false"`
}

type ConfigHttp

type ConfigHttp struct {
	CORES  string `env:"CORES,default=*"`
	Port   int64  `env:"Port,default=80"`
	Path   string `env:"Path,default=/"`
	Enable bool   `env:"Enable,default=false"`
	//MaxBufferSize is the max size of a task in bytes, default 10M
	MaxBufferSize int64 `env:"MaxBufferSize,default=10485760"`
}

type ConfigJWT

type ConfigJWT struct {
	Secret string `env:"Secret"`
	Fields string `env:"Fields"`
}

type ConfigRedis

type ConfigRedis struct {
	Name     string
	Username string `env:"Username"`
	Password string `env:"Password"`
	Host     string `env:"Host,required=true"`
	Port     string `env:"Port,required=true"`
	DB       int64  `env:"DB,required=true"`
}

type Configuration

type Configuration struct {
	//redis server, format: username:password@address:port/db
	Redis []*ConfigRedis
	Jwt   ConfigJWT
	Http  ConfigHttp
	Api   ConfigAPI
	Data  ConfigData
	//{"DebugLevel": 0,"InfoLevel": 1,"WarnLevel": 2,"ErrorLevel": 3,"FatalLevel": 4,"PanicLevel": 5,"NoLevel": 6,"Disabled": 7	  }
	LogLevel int8 `env:"LogLevel,default=1"`
}
var Cfg Configuration = Configuration{
	Redis:    []*ConfigRedis{},
	Jwt:      ConfigJWT{Secret: "", Fields: "*"},
	Http:     ConfigHttp{CORES: "*", Port: 80, Path: "/", Enable: false, MaxBufferSize: 10485760},
	Api:      ConfigAPI{ServiceBatchSize: 64},
	Data:     ConfigData{AutoAuth: false},
	LogLevel: 1,
}

set default values

Jump to

Keyboard shortcuts

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