config

package
v0.0.0-...-c676f21 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsecLocalTimeFormat = "2006-01-02 15:04:05.000"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CasbinConfiguration

type CasbinConfiguration struct {
	ModelPath string `mapstructure:"model-path" json:"modelPath"`
}

type Configuration

type Configuration struct {
	Server *ServerConfiguration `mapstructure:"server" json:"server"`
	Mysql  *MysqlConfiguration  `mapstructure:"mysql" json:"mysql"`
	Redis  *RedisConfiguration  `mapstructure:"redis" json:"redis"`
	Casbin *CasbinConfiguration `mapstructure:"casbin" json:"casbin"`
	Jwt    *JWTConfiguration    `mapstructure:"jwt" json:"jwt"`
	Log    *LogConfiguration    `mapstructure:"log" json:"log"`
}

viper内置了mapstructure, yml文件用"-"区分单词, 转为驼峰方便

type CustomConfBox

type CustomConfBox struct {
	// 配置文件所在文件目录
	ConfEnv string
	// 配置实例
	ViperIns *viper.Viper
}

自定义配置盒子,存放环境配置和对应的viper

func (*CustomConfBox) Find

func (c *CustomConfBox) Find(filename string) ([]byte, error)

查找配置文件

type JWTConfiguration

type JWTConfiguration struct {
	Realm      string `mapstructure:"realm" json:"realm" `
	Key        string `mapstructure:"key" json:"key"`
	Timeout    int    `mapstructure:"timeout" json:"timeout"`
	MaxRefresh int    `mapstructure:"max-refresh" json:"maxRefresh"`
}

type LogConfiguration

type LogConfiguration struct {
	Path       string        `mapstructure:"path" json:"path"`
	Level      zapcore.Level `mapstructure:"level" json:"level"`
	MaxSize    int           `mapstructure:"max-size" json:"maxSize"`
	MaxAge     int           `mapstructure:"max-age" json:"maxAge"`
	MaxBackups int           `mapstructure:"max-backups" json:"maxBackups"`
	Compress   bool          `mapstructure:"compress" json:"compress"`
}

type MysqlConfiguration

type MysqlConfiguration struct {
	Host                  string        `mapstructure:"host" json:"host"`
	Username              string        `mapstructure:"username" json:"username"`
	Password              string        `mapstructure:"password" json:"password"`
	Database              string        `mapstructure:"database" json:"database"`
	MaxIdleConnections    int           `mapstructure:"max-idle-connections" json:"maxIdleConnections"`
	MaxOpenConnections    int           `mapstructure:"max-open-connections" json:"maxOpenConnections"`
	MaxConnectionLifeTime time.Duration `mapstructure:"max-connection-life-time" json:"maxConnectionLifeTime"`
	LogLevel              int           `mapstructure:"log-level" json:"logLevel"`
}

type RedisConfiguration

type RedisConfiguration struct {
	Addr     string `mapstructure:"addr" json:"addr"`
	Password string `mapstructure:"password" json:"password"`
	Db       int    `mapstructure:"db" json:"db"`
}

type ServerConfiguration

type ServerConfiguration struct {
	Port                 int    `mapstructure:"port" json:"port"`
	Name                 string `mapstructure:"name" json:"name"`
	UrlPrefix            string `mapstructure:"url-prefix" json:"urlPrefix"`
	ApiVersion           string `mapstructure:"api-version" json:"apiVersion"`
	InitData             bool   `mapstructure:"init-data" json:"initData"`
	IdempotenceTokenName string `mapstructure:"idempotence-token-name" json:"idempotenceTokenName"`
}

Jump to

Keyboard shortcuts

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