conf.go 618 Bytes
Newer Older
kzkzzzz's avatar
kzkzzzz committed
1 2 3 4 5 6 7
package conf

import (
	"flag"
	"gomicro-base/common/conf"
	"gomicro-base/common/logz"
	"gomicro-base/common/mysql"
8
	"gomicro-base/common/redis"
kzkzzzz's avatar
kzkzzzz committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22
)

func init() {
	flag.StringVar(&confPath, "conf", "config/config.yaml", "配置文件路径")
}

var (
	confPath string
	Conf     = &Config{}
)

type Config struct {
	Server *Server
	Mysql  *mysql.Config
23
	Redis  *redis.Config
kzkzzzz's avatar
kzkzzzz committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
	Log    *logz.Config
}

type Server struct {
	Name         string
	ConsulServer []string
	EtcdServer   []string
	Grpc         struct {
		Addr string
	}
	Http struct {
		Addr string
	}
}

func LoadConfig() {
	conf.LoadFromYaml(confPath, &Conf)
}