config

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RunEnvDev  string = "dev"
	RunEnvProd string = "prod"
	Beans      string = "mysql,redis,mongo"
)

Variables

This section is empty.

Functions

func WatchConfig

func WatchConfig(cf *Config, opt *FlagOption) error

监听配置文件的修改和变动

Types

type Config

type Config struct {
	AppName            string `json:"app_name"`
	AppVersion         string `json:"app_version"`
	Conf               string
	Debug              bool
	RunEnv             string
	Beans              string
	Mysql              MysqlConfig
	Redis              RedisConfig
	Mq                 MqConfig
	Mongodb            MongodbConfig
	Log                LogConfig
	WorkNum            int    `json:"work_num"`
	UploadImageHost    string `json:"upload_image_host"`
	DownloadImageProxy string `json:"download_image_proxy"`
	// contains filtered or unexported fields
}

程序配置

func NewConfig

func NewConfig(opt *FlagOption) *Config

type FlagOption

type FlagOption struct {
	Debug  bool
	Conf   string
	RunEnv string
	Beans  string
}

=========flag

func NewFlagOption

func NewFlagOption() (opt *FlagOption)

type LogConfig

type LogConfig struct {
	LogDir string `json:"log_dir,omitempty"` //日志存放目录
	//MaxSize       int8   //日志文件最大
	//MaxBackups    int8   //最多备份数量
	Level         string //日志级别,只保留某级别以上日志 info error warning
	MaxAge        int16  `json:"max_age"`        //最多保留天数
	SplitDuration string `json:"split_duration"` //切割周期-天/月
}

type MongodbConfig

type MongodbConfig struct {
	Addrs      []string
	Username   string
	Password   string
	Dbname     string
	ReplicaSet string `json:"replica_set"`
	Engine     string
}

type MqConfig added in v1.1.6

type MqConfig struct {
	Addr       string
	InstanceId string
	Topic      string
}

type MysqlConfig

type MysqlConfig struct {
	Addr     string
	Username string
	Password string
	Charset  string
	Dbname   string
	Engine   string
}

type RedisConfig

type RedisConfig struct {
	Addr     string
	Password string
}

Jump to

Keyboard shortcuts

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