config

package
v0.0.0-...-570e58b Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func ConfigInit

func ConfigInit()

ConfigInit 初始化配置 将配置文件的信息反序列化到结构体中

func SaveConfig

func SaveConfig(configFile string, config *ProfileInfo) error

SaveConfig 将配置写入文件,并在失败时回滚

Types

type App

type App struct {
	Env         string `mapstructure:"env"`
	Cache       bool   `mapstructure:"cache"`
	ServiceName string `mapstructure:"service-name"`
	MachineID   int64  `mapstructure:"machine-id"`
	ServerPort  int    `mapstructure:"server-port"`
	ApiPrefix   string `mapstructure:"api-prefix"`
}

系统配置

type DllConfig

type DllConfig struct {
	DllPath string `mapstructure:"dll-path"`
	DllName string `mapstructure:"dll-name"`
}

dll加载配置

type JwtConfig

type JwtConfig struct {
	AccessExpire       int64  `mapstructure:"access-expire"`
	RefreshExpire      int64  `mapstructure:"refresh-expire"`
	Issuer             string `mapstructure:"issuer"`
	AccessTokenSecret  string `mapstructure:"asecret"`
	RefreshTokenSecret string `mapstructure:"rsecret"`
}

jwt配置

type MailConfig

type MailConfig struct {
	SmtpServer string `mapstructure:"smtp-server"`
	SmtpPort   int    `mapstructure:"smtp-port"`
	Writer     string `mapstructure:"email-writer"`
	Account    string `mapstructure:"account"`
	Password   string `mapstructure:"password"`
	BCC        string `mapstructure:"email-bcc"`
	CC         string `mapstructure:"email-cc"`
	URLPrefix  string `mapstructure:"url-prefix"`
}

dll加载配置

type MongoConfig

type MongoConfig struct {
	DBName string `mapstructure:"dbname"`
	URI    string `mapstructure:"uri"`
}

MongoDB配置

type MysqlConfig

type MysqlConfig struct {
	Host         string `mapstructure:"host"`
	Port         int    `mapstructure:"port"`
	User         string `mapstructure:"user"`
	Password     string `mapstructure:"password"`
	DBName       string `mapstructure:"dbname"`
	MaxIdleConns int    `mapstructure:"max-idle-conns" json:"max-idle-conns" yaml:"max-idle-conns"` // 空闲中的最大连接数
	MaxOpenConns int    `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns"` // 打开到数据库的最大连接数
}

mysql配置

type ObjStoreConfig

type ObjStoreConfig struct {
	//Endpoint     string `mapstructure:"endpoint"`
	Region     string `mapstructure:"region"`
	BucketName string `mapstructure:"bucket-name"`
	//EndpointExternal string `mapstructure:"endpoint-external"`
	AccessID     string `mapstructure:"access-id"`
	AccessSecret string `mapstructure:"access-secret"`
	RoleArn      string `mapstructure:"role-arn"`
}

type ProfileInfo

type ProfileInfo struct {
	*App            `mapstructure:"app"`
	*RedisConfig    `mapstructure:"redis"`
	*MysqlConfig    `mapstructure:"mysql"`
	*MongoConfig    `mapstructure:"mongo"`
	*JwtConfig      `mapstructure:"jwt"`
	*DllConfig      `mapstructure:"dll"`
	*MailConfig     `mapstructure:"mail"`
	*ObjStoreConfig `mapstructure:"obj-store"`
}

type RedisConfig

type RedisConfig struct {
	Addr     string `mapstructure:"addr"`
	Password string `mapstructure:"password"`
	DB       int    `mapstructure:"db"`
}

Redis配置

Jump to

Keyboard shortcuts

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