config.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package config
  2. import (
  3. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/resource"
  4. "github.com/zeromicro/go-zero/core/conf"
  5. "github.com/zeromicro/go-zero/core/discov"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. "github.com/zeromicro/go-zero/zrpc"
  8. "userCenter/entity"
  9. )
  10. type Config struct {
  11. zrpc.RpcServerConf
  12. FileSystemConf zrpc.RpcClientConf
  13. CalleeId string // 服务名字
  14. ResourceEtcdConf zrpc.RpcClientConf //资源中台
  15. Node int // 节点
  16. Mysql Mysql
  17. BaseMysql Mysql
  18. Logx logx.LogConf
  19. IsRun bool //定时任务是否开启
  20. CheckEntIsExpire string //
  21. DoMain string
  22. RedisAddrees []string
  23. RedisOutTime int
  24. InternalTime int
  25. Mongo struct {
  26. Main *MongoStruct
  27. }
  28. BigMemberOff bool
  29. }
  30. type MongoStruct struct {
  31. Address string `json:"address"`
  32. Size int `json:"size"`
  33. DbName string `json:"dbName"`
  34. UserName string `json:"userName,optional"`
  35. Password string `json:"password,optional"`
  36. Collection string `json:"collection,optional"`
  37. CollectionBack string `json:"collectionBack,optional"`
  38. MaxOpenConns int `json:"maxOpenConns,optional"`
  39. MaxIdleConns int `json:"maxIdleConns,optional"`
  40. }
  41. var (
  42. ConfigJson Config
  43. )
  44. type Mysql struct {
  45. DbName string `json:"dbName"`
  46. Address string `json:"address"`
  47. UserName string `json:"userName"`
  48. PassWord string `json:"passWord"`
  49. MaxOpenConns int `json:"maxOpenConns"`
  50. MaxIdleConns int `json:"maxIdleConns"`
  51. }
  52. func init() {
  53. conf.MustLoad("etc/usercenter.yaml", &ConfigJson)
  54. //初始化资源中台相关
  55. resourceClient := zrpc.MustNewClient(zrpc.RpcClientConf{
  56. Etcd: discov.EtcdConf{
  57. Hosts: ConfigJson.ResourceEtcdConf.Etcd.Hosts,
  58. Key: ConfigJson.ResourceEtcdConf.Etcd.Key,
  59. },
  60. })
  61. entity.ResourceLib = resource.NewResource(resourceClient)
  62. }