123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package config
- import (
- "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/resource"
- "github.com/zeromicro/go-zero/core/conf"
- "github.com/zeromicro/go-zero/core/discov"
- "github.com/zeromicro/go-zero/core/logx"
- "github.com/zeromicro/go-zero/zrpc"
- "userCenter/entity"
- )
- type Config struct {
- zrpc.RpcServerConf
- FileSystemConf zrpc.RpcClientConf
- CalleeId string // 服务名字
- ResourceEtcdConf zrpc.RpcClientConf //资源中台
- Node int // 节点
- Mysql Mysql
- BaseMysql Mysql
- Logx logx.LogConf
- IsRun bool //定时任务是否开启
- CheckEntIsExpire string //
- DoMain string
- RedisAddrees []string
- RedisOutTime int
- InternalTime int
- Mongo struct {
- Main *MongoStruct
- }
- BigMemberOff bool
- CommonlySize int //常用功能设置数量
- }
- type MongoStruct struct {
- Address string `json:"address"`
- Size int `json:"size"`
- DbName string `json:"dbName"`
- UserName string `json:"userName,optional"`
- Password string `json:"password,optional"`
- Collection string `json:"collection,optional"`
- CollectionBack string `json:"collectionBack,optional"`
- MaxOpenConns int `json:"maxOpenConns,optional"`
- MaxIdleConns int `json:"maxIdleConns,optional"`
- }
- var (
- ConfigJson Config
- )
- type Mysql struct {
- DbName string `json:"dbName"`
- Address string `json:"address"`
- UserName string `json:"userName"`
- PassWord string `json:"passWord"`
- MaxOpenConns int `json:"maxOpenConns"`
- MaxIdleConns int `json:"maxIdleConns"`
- }
- func init() {
- conf.MustLoad("etc/usercenter.yaml", &ConfigJson)
- //初始化资源中台相关
- resourceClient := zrpc.MustNewClient(zrpc.RpcClientConf{
- Etcd: discov.EtcdConf{
- Hosts: ConfigJson.ResourceEtcdConf.Etcd.Hosts,
- Key: ConfigJson.ResourceEtcdConf.Etcd.Key,
- },
- })
- entity.ResourceLib = resource.NewResource(resourceClient)
- }
|