config

package
v0.0.0-...-c58336e Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(file string)

Init 初始化配置

Types

type ConnInfo

type ConnInfo struct {
	Addr    string `yaml:"addr"`
	Timeout int    `yaml:"timeout"`
}

ConnInfo 接入服务信息

type CosInfo

type CosInfo struct {
	SecretID       string `yaml:"secret_id"`
	SecretKey      string `yaml:"secret_key"`
	Domain         string `yaml:"domain"`
	Region         string `yaml:"region"`
	DisableSSL     bool   `yaml:"disable_ssl"`
	ForcePathStyle bool   `yaml:"force_path_style"`
	AvatarBucket   string `yaml:"avatar_bucket"` // 头像专用
	MediaBucket    string `yaml:"media_bucket"`  // 媒体消息专用,包含图片,语音,文件
	Expire         int64  `yaml:"expire"`        // 单位小时
	SignFlag       bool   `yaml:"sign"`          // 是否需要签名,默认需要
}

type DBInfo

type DBInfo struct {
	// user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local
	Dsn          string `yaml:"dsn"`
	MaxIdleConns int    `yaml:"max_idle_conns"`
	MaxOpenConns int    `yaml:"max_open_conns"`
	MaxLifeTime  int    `yaml:"max_life_time"` // 单位秒
}

DBInfo db信息

type LogInfo

type LogInfo struct {
	Path       string `yaml:"path"`
	Level      int    `yaml:"level"`
	MaxSize    int    `yaml:"max_size"` // mb
	MaxAge     int    `yaml:"max_age"`  // day
	MaxBackUps int    `yaml:"max_backups"`
	CallerSkip int    `yaml:"caller_skip"`
}

type ServerCfg

type ServerCfg struct {
	ServerInfo *ServerInfo `yaml:"server"`
	DBInfo     *DBInfo     `yaml:"db"`
	ConnInfo   *ConnInfo   `yaml:"conn"`
	CosInfo    *CosInfo    `yaml:"cos"`
	LogInfo    *LogInfo    `yaml:"log"`
}

func AppConfig

func AppConfig() *ServerCfg

AppConfig 获取配置单例

type ServerInfo

type ServerInfo struct {
	Name          string `yaml:"name"`
	Listen        string `yaml:"listen"`
	Timeout       int    `yaml:"timeout"`
	Secret        string `yaml:"secret"`
	TokenExpire   int    `yaml:"token_expire"`
	DataCenterId  int64  `yaml:"data_center_id"`
	DebugReqRsp   bool   `yaml:"debug_req_rsp"`
	ResourceRoot  string `yaml:"resource_root"`
	RemoteUrlRoot string `yaml:"remote_url_root"`
	Mode          string `yaml:"mode"` // debug, release, test
}

Jump to

Keyboard shortcuts

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