1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package utility
- import (
- elastic "app.yhyue.com/moapp/jybase/es"
- "app.yhyue.com/moapp/jypkg/middleground"
- "github.com/gogf/gf/v2/frame/g"
- "github.com/gogf/gf/v2/os/gctx"
- )
- type (
- mgoConf struct {
- Address string
- Size int
- DbName string
- ReplSet string
- UserName string
- Password string
- Collection string
- Collection_back string
- }
- esConf struct {
- Address string
- Size int
- Version string
- UserName string
- Password string
- }
- )
- var (
- elasticConf, otherElasticConf esConf
- RedisTime int64
- PortraitCount int
- OtherElastic elastic.Es
- Middleground *middleground.Middleground
- )
- func init() {
- initCtx := gctx.New()
- if err := g.Cfg().MustGet(initCtx, "elasticsearch.default").Struct(&elasticConf); err == nil {
- elastic.NewEs(elasticConf.Version, elasticConf.Address, elasticConf.Size, elasticConf.UserName, elasticConf.Password)
- }
- if err := g.Cfg().MustGet(initCtx, "elasticsearch.other").Struct(&otherElasticConf); err == nil {
- OtherElastic = &elastic.EsV7{
- Address: otherElasticConf.Address,
- UserName: otherElasticConf.UserName,
- Password: otherElasticConf.Password,
- Size: otherElasticConf.Size,
- }
- OtherElastic.Init()
- }
- g.Log().Info(initCtx, "初始化 elastic 完成")
- RedisTime = g.Cfg().MustGet(initCtx, "redisTime", 7).Int64()
- PortraitCount = g.Cfg().MustGet(initCtx, "PortraitCount", 30).Int()
- Middleground = middleground.NewMiddleground(g.Cfg().MustGet(initCtx, "etcd.hosts").Strings()).
- RegPowerCheckCenter(g.Cfg().MustGet(initCtx, "powerCheckCenterKey").String())
- }
|