databus.go 695 B

123456789101112131415161718192021222324252627282930
  1. package dao
  2. import (
  3. "context"
  4. "strconv"
  5. "time"
  6. "go-common/app/job/main/thumbup/model"
  7. "go-common/library/log"
  8. )
  9. // PubStatDatabus .
  10. func (d *Dao) PubStatDatabus(c context.Context, business string, mid int64, s *model.Stats, upMid int64) (err error) {
  11. msg := &model.StatMsg{
  12. Type: business,
  13. ID: s.ID,
  14. Count: s.Likes,
  15. Timestamp: time.Now().Unix(),
  16. OriginID: s.OriginID,
  17. DislikeCount: s.Dislikes,
  18. Mid: mid,
  19. UpMid: upMid,
  20. }
  21. if err = d.statDbus.Send(c, strconv.FormatInt(s.ID, 10), msg); err != nil {
  22. log.Error("d.statDbus.Send error(%v)", err)
  23. return
  24. }
  25. log.Info("pub stat databus success params(%+v)", msg)
  26. return
  27. }