config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2019 License: MIT Imports: 4 Imported by: 0

README

配置目录说明

  • 动态配置项基于yaml文件,编译后启动时可传入config目录启动;
  • 根据debug、release、test三种环境载入配置,配置文件于对应环境的目录中;
  • 可使用ginger-cli工具,根据yaml文件生成配置项解析代码;
  • 除yaml文件配置外,配置项也可用常数;

Documentation

Index

Constants

View Source
const (
	AppName    = "ginger"
	AppVersion = "v0.2.0"
	// 环境变量未设置时的默认值,默认使用开发环境配置
	DefaultEnv = gin.DebugMode
	// jwt编码时的私钥字符串
	TokenPrivateKey = "ginger"
)

常量级参数配置项,编译前设置值

Variables

View Source
var (
	BaseConf  Base
	LogConf   Log
	MysqlConf Mysql
	RedisConf Redis
	MongoConf Mongodb
)

Functions

func Init

func Init(confPath string)

动态参数配置项,编译后可携yaml配置文件启动

Types

type Base

type Base struct {
	Env        string `yaml:"env"`
	ListenPort int64  `yaml:"listen"`
}

type Log

type Log struct {
	LogDir                     string `yaml:"logDir"`
	LogMaxDayCount             int    `yaml:"maxDayCount"`
	LogMongoHookOn             bool   `yaml:"logMongoHookOn"`
	LogMongoCollection         string `yaml:"logMongoCol"`
	LogMongoExpireAfterSeconds int    `yaml:"logMongoExpire"`
	WithRotationTime           int    `yaml:"withRotationTime"`
}

type Mongodb

type Mongodb struct {
	DbHost   string `yaml:"dbHost"`
	DbPort   int64  `yaml:"dbPort"`
	DbUser   string `yaml:"dbUser"`
	DbPasswd string `yaml:"dbPasswd"`
	DbName   string `yaml:"dbName"`
}

type Mysql

type Mysql struct {
	DbHost                  string `yaml:"dbHost"`
	DbPort                  int64  `yaml:"dbPort"`
	DbUser                  string `yaml:"dbUser"`
	DbPasswd                string `yaml:"dbPasswd"`
	DbName                  string `yaml:"dbName"`
	ConnMaxLifetime         int64  `yaml:"connMaxLifetime"`
	MaxIdleConns            int64  `yaml:"maxIdleConns"`
	MaxOpenConns            int64  `yaml:"maxOpenConns"`
	ChartSet                string `yaml:"charset"`
	AllowCleartextPasswords bool   `yaml:"allowCleartextPasswords"`
	InterpolateParams       bool   `yaml:"interpolateParams"`
	Timeout                 int64  `yaml:"timeout"`
	ReadTimeout             int64  `yaml:"readTimeout"`
	ParseTime               bool   `yaml:"parseTime"`
	PING                    bool   `yaml:"ping"`
}

type Redis

type Redis struct {
	DbHost      string `yaml:"dbHost"`
	DbPort      int64  `yaml:"dbPort"`
	DbAuth      bool   `yaml:"dbAuth"`
	DbPasswd    string `yaml:"dbPasswd"`
	MaxActive   int64  `yaml:"maxActive"`
	MaxIdle     int64  `yaml:"maxIdle"`
	IdleTimeout int64  `yaml:"idleTimeout"`
}

Jump to

Keyboard shortcuts

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