conf.go 665 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 23
)

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

var (
	confPath string
	Conf     = &Config{}
)

type Config struct {
	Server *Server
	Client *Client
	Mysql  *mysql.Config
24
	Redis  *redis.Config
kzkzzzz's avatar
kzkzzzz committed
25 26 27 28
	Log    *logz.Config
}

type Server struct {
kzkzzzz's avatar
kzkzzzz committed
29 30 31 32
	Name       string
	ConsulAddr []string
	EtcdAddr   []string
	Grpc       struct {
kzkzzzz's avatar
kzkzzzz committed
33 34 35 36 37 38 39 40
		Addr string
	}
	Http struct {
		Addr string
	}
}

type Client struct {
41
	Member string
kzkzzzz's avatar
kzkzzzz committed
42 43 44 45 46
}

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