config.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. <<<<<<< HEAD
  23. RedisAddrees []string
  24. RedisOutTime int64
  25. InternalTime int64
  26. Mongo struct {
  27. Main *MongoStruct
  28. }
  29. BigMemberOff bool
  30. CommonlySize int64 //常用功能设置数量
  31. ManagerUserIds []string
  32. UserRolePower []string
  33. }
  34. type MongoStruct struct {
  35. Address string `json:"address"`
  36. Size int `json:"size"`
  37. DbName string `json:"dbName"`
  38. UserName string `json:"userName,optional"`
  39. Password string `json:"password,optional"`
  40. Collection string `json:"collection,optional"`
  41. CollectionBack string `json:"collectionBack,optional"`
  42. MaxOpenConns int `json:"maxOpenConns,optional"`
  43. MaxIdleConns int `json:"maxIdleConns,optional"`
  44. =======
  45. Mongo Mongodb
  46. >>>>>>> master
  47. }
  48. var (
  49. ConfigJson Config
  50. ManagerUserIdsMap = map[string]bool{}
  51. )
  52. type Mongodb struct {
  53. DbName string `json:"dbName"`
  54. Size int `json:"size"`
  55. Address string `json:"address"`
  56. }
  57. type Mysql struct {
  58. DbName string `json:"dbName"`
  59. Address string `json:"address"`
  60. UserName string `json:"userName"`
  61. PassWord string `json:"passWord"`
  62. MaxOpenConns int `json:"maxOpenConns"`
  63. MaxIdleConns int `json:"maxIdleConns"`
  64. }
  65. func init() {
  66. conf.MustLoad("etc/usercenter.yaml", &ConfigJson)
  67. //初始化资源中台相关
  68. resourceClient := zrpc.MustNewClient(zrpc.RpcClientConf{
  69. Etcd: discov.EtcdConf{
  70. Hosts: ConfigJson.ResourceEtcdConf.Etcd.Hosts,
  71. Key: ConfigJson.ResourceEtcdConf.Etcd.Key,
  72. },
  73. })
  74. entity.ResourceLib = resource.NewResource(resourceClient)
  75. //
  76. if len(ConfigJson.ManagerUserIds) > 0 {
  77. for _, v := range ConfigJson.ManagerUserIds {
  78. ManagerUserIdsMap[v] = true
  79. }
  80. }
  81. }