config

package
v0.0.0-...-75bc1fc Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProdEnv  = "production" //线上环境
	BetaEnv  = "beta"       //beta环境
	DevEnv   = "develop"    //开发环境
	LocalEnv = "local"      //本地环境
)

Variables

This section is empty.

Functions

func GetEnv

func GetEnv() string

当前环境,默认本地开发

func IsDebug

func IsDebug() bool

是否调试模式

func IsEnvEqual

func IsEnvEqual(env string) bool

是否当前环境

Types

type CacheConfig

type CacheConfig struct {
	Driver string //驱动类型,目前支持redis
}

type Config

type Config struct {
	Debug      bool        `toml:"Debug"`
	LogHandler string      `toml:"LogHandler"`
	LogDir     string      `toml:"LogDir"`
	LogLevel   string      `toml:"LogLevel"`
	Env        string      `toml:"Env"`
	Cache      CacheConfig `toml:"cache"`
	Redis      RedisConfig `toml:"Redis"`
	Mns        MnsConfig   `toml:"AliMns"`
	Db         DbConfig    `toml:"Db"`

	Api struct {
		Host string
		Port int
	} `toml:"Api"`
}

func GetConf

func GetConf() *Config

当前配置

func Load

func Load(path string) (*Config, error)

------------------------ 加载配置 ------------------------//

type DbBaseConfig

type DbBaseConfig struct {
	Host     string
	Port     int
	User     string
	Password string
	DBName   string
}

type DbConfig

type DbConfig struct {
	Driver string //驱动类型,目前支持mysql、postgres、mssql、sqlite3
	Master DbBaseConfig
	Slaves []DbBaseConfig
	Option DbOptionConfig
}

type DbOptionConfig

type DbOptionConfig struct {
	MaxIdle        int
	MaxConns       int
	IdleTimeout    time.Duration
	ConnectTimeout time.Duration
	Charset        string
}

type MnsConfig

type MnsConfig struct {
	Url             string
	AccessKeyId     string
	AccessKeySecret string
}

type Options

type Options struct {
	ShowVersion bool
	Cmd         string
	ConfFile    string
	App         string
	PidPath     string
	Queue       string
}

------------------------启动命令配置

func GetOptions

func GetOptions() *Options

获取启动命令配置

type RedisBaseConfig

type RedisBaseConfig struct {
	Host     string
	Port     int
	Password string
	DB       int //第几个库,默认0
}

type RedisConfig

type RedisConfig struct {
	Master RedisBaseConfig
	Slaves []RedisBaseConfig
	Option RedisOptionConfig
}

type RedisOptionConfig

type RedisOptionConfig struct {
	MaxIdle        int
	MaxConns       int
	Wait           bool
	IdleTimeout    time.Duration
	ConnectTimeout time.Duration
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
}

Jump to

Keyboard shortcuts

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