conf

package
v0.0.0-...-0cf7bf9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfigFromEnv

func LoadConfigFromEnv()

从环境变量中加载配置

func LoadConfigFromToml

func LoadConfigFromToml()

从toml格式的配置文件中加载

Types

type App

type App struct {
	Nmae string `toml:"name"`
	Host string `toml:"host"`
	Port string `toml:"port"`
	Key  string `toml:"key"`
}

type Config

type Config struct {
	App   *App   `toml:"app"`
	Log   *Log   `toml:"log"`
	MySQL *MySQL `toml:"mysql"`
}

config 应用配置 通过封装成一个对象,来与外部进行对接

type Log

type Log struct {
	Level   string `toml:"level" env:"LOG_LEVEL"`
	PathDir string `toml:"pathdir" env:"LOG_PATH_DIR"`
}

type MySQL

type MySQL struct {
	Host     string `toml:"host" env:"MYSQL_HOST"`
	Port     string `toml:"port" env:"MYSQL_PORT"`
	Username string `toml:"username" env:"MYSQL_USERNAME"`
	Password string `toml:"password" env:"MYSQL_PASSWORD"`
	Database string `toml:"database" env:"MYSQL_DATABASE"`
	//应为使用的是mysql连接池,需要规划使用池的配置
	//控制当前程序最多可以打开的mysql连接数
	MaxOpenConn int `toml:"maxopenconn" env:"MYSQL_MAXOPENCONN"`
	//控制mysql服用,
	MaxIdleConn int `toml:"maxidleconn" env:"MYSQL_MAXIDLECONN"`
	//一个链接的生命周期,和mysql配置也相联系
	MaxLifeTime int `toml:"maxlifetime" env:"MYSQL_MAXLIFETIME"`
	//空闲链接的超时时常
	MaxIdleTime int `toml:"maxidletime" env:"MYSQL_MAXIDLETIME"`
}

Jump to

Keyboard shortcuts

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