config

package
v0.0.0-...-52c6137 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Conf = &Config{}

Conf @Description: 全局配置变量

Functions

func LoadConfig

func LoadConfig(confPath string) (*viper.Viper, error)

LoadConfig @Description: 使用viper加载指定文件夹下的配置文件 @param confPath @return *viper.Viper @return error

func WatchConfig

func WatchConfig(v *viper.Viper)

WatchConfig @Description: 监控配置文件变化并热加载程序 @param v

Types

type AppConfig

type AppConfig struct {
	Name      string
	Version   string
	Mode      string
	PprofPort string
	URL       string
	SSL       bool
	CSRF      bool
	Debug     bool
}

AppConfig @Description: 框架配置

type Config

type Config struct {
	App  AppConfig
	Http HttpConfig
	Grpc GrpcConfig

	Log    LogConfig
	Mysql  MysqlConfigs
	Redis  RedisConfig
	Email  EmailConfig
	Trace  TraceConfig
	Jaeger JaegerConfig
}

Config @Description: 全局配置

func Init

func Init(confPath string) (*Config, error)

func ParseConfig

func ParseConfig(v *viper.Viper) (*Config, error)

ParseConfig @Description:使用viper解析配置文件到全局结构体中 @param v @return *Config @return error

type EmailConfig

type EmailConfig struct {
	Host      string
	Port      int
	Username  string
	Password  string
	Name      string
	Address   string
	ReplyTo   string
	KeepAlive int
}

EmailConfig @Description: 邮件配置

type GrpcConfig

type GrpcConfig struct {
	Addr         string
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

GrpcConfig @Description: grpc服务配置

type HttpConfig

type HttpConfig struct {
	Addr         string
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

HttpConfig @Description: http服务配置

type JaegerConfig

type JaegerConfig struct {
	SamplingServerURL      string  // Set the sampling server url
	SamplingType           string  // Set the sampling type
	SamplingParam          float64 // Set the sampling parameter
	LocalAgentHostPort     string  // Set jaeger-agent's host:port that the reporter will used
	Gen128Bit              bool    // Generate 128 bit span IDs
	Propagation            string  // Which propagation format to use (jaeger/b3)
	TraceContextHeaderName string  // Set the header to use for the trace-id
	CollectorEndpoint      string  // Instructs reporter to send spans to jaeger-collector at this URL
	CollectorUser          string  // CollectorUser for basic http authentication when sending spans to jaeger-collector
	CollectorPassword      string  // CollectorPassword for basic http authentication when sending spans to jaeger
}

JaegerConfig @Description: 链路追踪Jaeger配置

type LogConfig

type LogConfig struct {
	Name              string
	Development       bool
	DisableCaller     bool
	DisableStacktrace bool
	Encoding          string
	Level             string
	Writers           string
	FormatText        bool
	RollingPolicy     string
	RotateDate        int
	RotateSize        int
	BackupCount       uint
	File              string
	WarnFile          string
	ErrorFile         string
}

LogConfig @Description: 日志配置文件

type MysqlConfig

type MysqlConfig struct {
	Name            string
	Addr            string
	UserName        string
	Password        string
	ShowLog         bool
	MaxIdleConn     int
	MaxOpenConn     int
	ConnMaxLifeTime time.Duration
}

MysqlConfig @Description: mysql配置

type MysqlConfigs

type MysqlConfigs map[string]MysqlConfig

type RedisConfig

type RedisConfig struct {
	Addr         string
	Password     string
	DB           int
	MinIdleConn  int
	DialTimeout  time.Duration
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	PoolSize     int
	PoolTimeout  time.Duration
}

RedisConfig @Description: redis 配置

type TraceConfig

type TraceConfig struct {
	ServiceName string

	TraceAgent string
	// contains filtered or unexported fields
}

TraceConfig @Description: 链路追踪配置

Jump to

Keyboard shortcuts

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