data.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package dao
  2. import (
  3. "encoding/json"
  4. "go-common/app/service/live/live-dm/conf"
  5. titansSdk "go-common/app/service/live/resource/sdk"
  6. "go-common/library/log"
  7. "go-common/library/log/infoc"
  8. "go-common/library/queue/databus"
  9. )
  10. var (
  11. //拜年祭投递databus
  12. bndatabus *databus.Databus
  13. //InfocDMSend 弹幕发送成功上报
  14. InfocDMSend *infoc.Infoc
  15. //InfocDMErr 弹幕发送失败上报
  16. InfocDMErr *infoc.Infoc
  17. )
  18. //InitDatabus 初始化databus
  19. func InitDatabus(c *conf.Config) {
  20. bndatabus = databus.New(c.BNDatabus)
  21. }
  22. //InitLancer 初始化lancer上报
  23. func InitLancer(c *conf.Config) {
  24. InfocDMErr = infoc.New(c.Lancer.DMErr)
  25. InfocDMSend = infoc.New(c.Lancer.DMSend)
  26. }
  27. //InitTitan 初始化kv配置
  28. func InitTitan() {
  29. conf := &titansSdk.Config{
  30. TreeId: 72389,
  31. Expire: 1,
  32. }
  33. titansSdk.Init(conf)
  34. }
  35. //LimitConf 弹幕限制配置
  36. type LimitConf struct {
  37. AreaLimit bool `json:"areaLimit"`
  38. AllUserLimit bool `json:"AllUserLimit"`
  39. LevelLimitStatus bool `json:"LevelLimitStatus"`
  40. LevelLimit int64 `json:"LevelLimit"`
  41. RealName bool `json:"RealName"`
  42. PhoneLimit bool `json:"PhoneLimit"`
  43. MsgLength int `json:"MsgLength"`
  44. DmNum int64 `json:"DmNum"`
  45. DMPercent int64 `json:"DMPercent"`
  46. DMwhitelist bool `json:"DMwhitelist"`
  47. DMwhitelistID string `json:"DMwhitelistID"`
  48. }
  49. //GetDMCheckConf 获取弹幕配置参数
  50. func (l *LimitConf) GetDMCheckConf() {
  51. cf, err := titansSdk.Get("dmLimit")
  52. if err != nil {
  53. log.Error("DM: get conf err:%+v", err)
  54. return
  55. }
  56. conf := &LimitConf{}
  57. err = json.Unmarshal([]byte(cf), conf)
  58. if err != nil {
  59. log.Error("DM: decode conf jsons err:%+v conf:%s", err, cf)
  60. return
  61. }
  62. l.AreaLimit = conf.AreaLimit
  63. l.AllUserLimit = conf.AllUserLimit
  64. l.LevelLimitStatus = conf.LevelLimitStatus
  65. l.LevelLimit = conf.LevelLimit
  66. l.RealName = conf.RealName
  67. l.PhoneLimit = conf.PhoneLimit
  68. l.DmNum = conf.DmNum
  69. l.DMwhitelist = conf.DMwhitelist
  70. l.DMPercent = conf.DMPercent
  71. l.MsgLength = conf.MsgLength
  72. l.DMwhitelistID = conf.DMwhitelistID
  73. }