Merge pull request 'by Robin at 20240530' (#520) from feat-IRONFANS-58-Robin into test
Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/520
This commit is contained in:
commit
ce2d7f7260
|
@ -47,16 +47,12 @@ func (s *StreamerRecommService) SetOut(out func([]int64) error) {
|
|||
func (s *StreamerRecommService) RunBatch(nt int64) error {
|
||||
ctx := &gin.Context{}
|
||||
|
||||
// 获取计算公式
|
||||
s.formula = &apollostruct.StreamerScoreFormulaCfg{}
|
||||
err := apollo.GetJson(consts.StreamerScoreFormulaKey, s.formula, apollo.ApolloOpts().SetNamespace("application"))
|
||||
err := s.init()
|
||||
if err != nil {
|
||||
logger.Error("Apollo read failed : %v", err)
|
||||
logger.Error("init fail, err: %v", err)
|
||||
s.clear()
|
||||
return fmt.Errorf("apollo read failed : %v", err)
|
||||
return err
|
||||
}
|
||||
// 获取优先级
|
||||
s.formula.CalPriority()
|
||||
|
||||
// 取数
|
||||
err = s.recvMsg(ctx, nt)
|
||||
|
@ -92,6 +88,22 @@ func (s *StreamerRecommService) RunBatch(nt int64) error {
|
|||
|
||||
}
|
||||
|
||||
func (s *StreamerRecommService) init() error {
|
||||
s.clear()
|
||||
|
||||
// 获取计算公式
|
||||
s.formula = &apollostruct.StreamerScoreFormulaCfg{}
|
||||
err := apollo.GetJson(consts.StreamerScoreFormulaKey, s.formula, apollo.ApolloOpts().SetNamespace("application"))
|
||||
if err != nil {
|
||||
logger.Error("Apollo read failed : %v", err)
|
||||
s.clear()
|
||||
return fmt.Errorf("apollo read failed : %v", err)
|
||||
}
|
||||
// 获取优先级
|
||||
s.formula.CalPriority()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *StreamerRecommService) clear() {
|
||||
s.scorelist = make([]*StreamerScore, 0)
|
||||
s.scores = make(map[int64]*StreamerScore)
|
||||
|
|
Loading…
Reference in New Issue