蛋蛋星球RabbitMq消费项目
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

77 строки
3.8 KiB

  1. package consume
  2. import (
  3. "applet/app/utils/logx"
  4. consumeMd "applet/consume/md"
  5. "time"
  6. )
  7. var (
  8. jobs = map[string]func(consumeMd.MqQueue){}
  9. )
  10. func Init() {
  11. // 初始化任务列表
  12. initConsumes()
  13. }
  14. // 增加消费任务队列
  15. func initConsumes() {
  16. jobs[consumeMd.AliyunSmsRecordFunName] = AliyunSmsRecordConsume //阿里云短信
  17. jobs[consumeMd.JpushRecordFunName] = JpushRecordConsume //极光推送
  18. jobs[consumeMd.UserDeleteFunName] = UserDeleteConsume // 用户注销处理
  19. jobs[consumeMd.EggEnergyNewUserRegisterDataFunName] = EggEnergyNewUserRegisterDataConsume // 新用户注册
  20. jobs[consumeMd.IMEggEnergyBatchSendMessageDataFunName] = IMEggEnergyBatchSendMessageDataConsume // 批量发送信息
  21. jobs[consumeMd.IMEggEnergyDelFriendCircleDataFunName] = IMEggEnergyDelFriendCircleDataConsume // 删除朋友圈
  22. jobs[consumeMd.EggFinWithdrawApplyDataConsumeFunName] = EggFinWithdrawApplyDataConsume // 提现
  23. jobs[consumeMd.EggEnergyDealUserECPMFunName] = EggEnergyDealUserECPMConsume // 处理给用户Ecpm值
  24. jobs[consumeMd.EggCanalInviteUserNumsFunName] = EggCanalInviteUserNumsConsume // 处理拉新人数
  25. jobs[consumeMd.EggCanalViolateNumsFunName] = EggCanalViolateNumsConsume // 处理违规次数
  26. jobs[consumeMd.IMEggEnergySendRedPackageFunName] = IMEggEnergySendRedPackageConsume // 处理用户发送红包次数
  27. jobs[consumeMd.VideoRewardFunName] = VideoRewardConsume // 短视频奖励
  28. jobs[consumeMd.PlayletRewardFunName] = PlayletRewardConsume // 短剧奖励
  29. jobs[consumeMd.EggEnergyDealUserECPMFunName] = EggEnergyDealUserECPMConsume // 处理给用户Ecpm值
  30. jobs[consumeMd.EggCanalInviteUserNumsFunName] = EggCanalInviteUserNumsConsume // 处理拉新人数
  31. jobs[consumeMd.EggCanalViolateNumsFunName] = EggCanalViolateNumsConsume // 处理违规次数
  32. jobs[consumeMd.IMEggEnergySendRedPackageFunName] = IMEggEnergySendRedPackageConsume // 处理用户发送红包次数
  33. jobs[consumeMd.EggCanalPersonAddActivityValueFunName] = EggCanalPersonAddActivityValueConsume // 用户活跃积分变更时更新es
  34. jobs[consumeMd.EggEnergyDealPlatformRevenueDataFunName] = EggEnergyDealPlatformRevenueDataConsume // 平台营收
  35. jobs[consumeMd.EggEnergyDealFundDataFunName] = EggEnergyDealFundDataConsume // 资金数据
  36. jobs[consumeMd.EggEnergyDealUserVirtualCoinDataFunName] = EggEnergyDealUserVirtualCoinDataConsume // 视频奖励给相应团队发放积分
  37. jobs[consumeMd.EggRecordActiveDataFunName] = EggRecordActiveDataConsume // 用户签到后更新活跃数据
  38. jobs[consumeMd.EggEnergyStartLevelDividendFunName] = EggEnergyStartLevelDividendConsume
  39. jobs[consumeMd.EggEnergySettlementPublicGiveActivityCoinFunName] = EggEnergySettlementPublicGiveActivityCoinConsume
  40. jobs[consumeMd.EggEnergyStartExchangeGreenEnergyFunName] = EggEnergyStartExchangeGreenEnergyConsume
  41. jobs[consumeMd.EggEnergyAutoExchangeGreenEnergyFunName] = EggEnergyAutoExchangeGreenEnergyConsume
  42. jobs[consumeMd.EggEnergyAutoScoreDataFunName] = EggEnergyAutoScoreConsume // 自动打分
  43. }
  44. func Run() {
  45. for _, v := range consumeMd.RabbitMqQueueKeyList {
  46. if _, ok := jobs[v.ConsumeFunName]; ok {
  47. go doConsume(v.ConsumeFunName, *v)()
  48. }
  49. }
  50. }
  51. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  52. return func() {
  53. begin := time.Now().Local()
  54. jobs[fnName](queue)
  55. end := time.Now().Local()
  56. logx.Infof(
  57. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  58. fnName,
  59. begin.Format("2006-01-02 15:04:05.000"),
  60. end.Format("2006-01-02 15:04:05.000"),
  61. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  62. )
  63. }
  64. }