config

package
v0.0.0-...-35f9073 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MySQL = iota
	PgSQL
)

DB enum

Variables

View Source
var (
	DB          *sqlx.DB
	RedisClient *redis.Client
)

Global

View Source
var C = struct {
	Port        string    `yaml:"port"`
	WaitTimeout int       `yaml:"wait_timeout"`
	Log         Log       `yaml:"log"`
	MySQLConf   *ConnConf `yaml:"mysql"`
	PgSQLConf   *ConnConf `yaml:"pgsql"`
	RedisConf   *ConnConf `yaml:"redis"`
}{}

C 通用配置

Functions

func Close

func Close()

Close 后续优化

func Connect

func Connect(driverType int, option *ConnConf)

Connect ...

func InitMysql

func InitMysql(conn *ConnConf) (driverName, dsn string)

InitMysql ...

func InitPgSQL

func InitPgSQL(conn *ConnConf) (driverName, dsn string)

InitPgSQL ...

func InitRedis

func InitRedis(conn *ConnConf)

InitRedis ...

Types

type ConnConf

type ConnConf struct {
	Host         string `yaml:"host"`
	User         string `yaml:"user"`
	Password     string `yaml:"password"`
	Port         int    `yaml:"port"`
	Database     string `yaml:"database"`
	ConnTimeout  int    `yaml:"conn_timeout"`
	ReadTimeout  int    `yaml:"read_timeout"`
	WriteTimeout int    `yaml:"write_timeout"`
}

ConnConf ...

type Log

type Log struct {
	Level      string `yaml:"level"`
	LineLevel  string `yaml:"line_level"`
	AsyncCount int64  `yaml:"async_count"`
}

Log ...

Jump to

Keyboard shortcuts

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