蛋蛋星球RabbitMq消费项目
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

92 wiersze
5.1 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.EggCanalUserUpConsume] = EggCanalUserUpConsume // 自动升级
  17. jobs[consumeMd.EggCanalUserDownConsume] = EggCanalUserDownConsume // 自动降级
  18. jobs[consumeMd.EggSlowAutoUpLvConsume] = EggSlowAutoUpLvConsume //缓慢 自动升级
  19. jobs[consumeMd.EggEnergyUserActivityConsume] = EggEnergyUserActivityConsume //监听 自动升级
  20. jobs[consumeMd.EggCanalUserConsume] = EggCanalUserConsume //监听 自动升级
  21. jobs[consumeMd.AliyunSmsRecordFunName] = AliyunSmsRecordConsume //阿里云短信
  22. jobs[consumeMd.JpushRecordFunName] = JpushRecordConsume //极光推送
  23. jobs[consumeMd.UserDeleteFunName] = UserDeleteConsume // 用户注销处理
  24. jobs[consumeMd.EggEnergyNewUserRegisterDataFunName] = EggEnergyNewUserRegisterDataConsume // 新用户注册
  25. jobs[consumeMd.IMEggEnergyBatchSendMessageDataFunName] = IMEggEnergyBatchSendMessageDataConsume // 批量发送信息
  26. jobs[consumeMd.IMEggEnergyDelFriendCircleDataFunName] = IMEggEnergyDelFriendCircleDataConsume // 删除朋友圈
  27. jobs[consumeMd.EggFinWithdrawApplyDataConsumeFunName] = EggFinWithdrawApplyDataConsume // 提现
  28. jobs[consumeMd.EggEnergyDealUserECPMFunName] = EggEnergyDealUserECPMConsume // 处理给用户Ecpm值
  29. //jobs[consumeMd.EggEnergyTemporaryDealUserECPMFunName] = TemporaryEggEnergyDealUserECPMConsume // 临时处理给用户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.EggRecordActiveDataFunName] = EggRecordActiveDataConsume // 用户签到后更新活跃数据
  35. jobs[consumeMd.EggEnergyAutoScoreDataFunName] = EggEnergyAutoScoreConsume // 自动打分
  36. jobs[consumeMd.EggSendFriendCircleDataFunName] = EggSendFriendCircleDataConsume // 用户发送朋友圈后更新es
  37. jobs[consumeMd.EggCommentDataFunName] = EggCommentDataConsume // 用户评论后更新es
  38. jobs[consumeMd.EggCanalEnergyExchangeAccountFunName] = EggCanalEnergyExchangeAccountConsume // 蛋蛋能量兑换为余额的时候更新es
  39. jobs[consumeMd.VideoRewardFunName] = VideoRewardConsume // 短视频奖励
  40. jobs[consumeMd.PlayletRewardFunName] = PlayletRewardConsume // 短剧奖励
  41. jobs[consumeMd.EggEnergyDealPlatformRevenueDataFunName] = EggEnergyDealPlatformRevenueDataConsume // 平台营收
  42. jobs[consumeMd.EggEnergyDealFundDataFunName] = EggEnergyDealFundDataConsume // 资金数据
  43. jobs[consumeMd.EggEnergyDealUserVirtualCoinDataFunName] = EggEnergyDealUserVirtualCoinDataConsume // 视频奖励给相应团队发放积分
  44. jobs[consumeMd.PublicPlatoonUserRelationCommissionConsumeFunName] = AddPublicPlatoonUserRelationCommissionConsume
  45. jobs[consumeMd.EggEnergyStartLevelDividendFunName] = EggEnergyStartLevelDividendConsume
  46. jobs[consumeMd.EggEnergySettlementPublicGiveActivityCoinFunName] = EggEnergySettlementPublicGiveActivityCoinConsume
  47. jobs[consumeMd.EggEnergyStartExchangeGreenEnergyFunName] = EggEnergyStartExchangeGreenEnergyConsume
  48. jobs[consumeMd.EggEnergyAutoExchangeGreenEnergyFunName] = EggEnergyAutoExchangeGreenEnergyConsume
  49. //jobs[consumeMd.EggEnergyRecruitNewUserRewardFunName] = EggEnergyRecruitNewUserRewardConsume //TODO::废弃
  50. jobs[consumeMd.EggEnergyTeamAssistanceConsumeFunName] = EggEnergyTeamAssistanceConsume // 更新团队助力数据
  51. jobs[consumeMd.EggCanalUserVirtualCoinFlowAggregationConsumeFunName] = EggCanalUserVirtualCoinFlowAggregationConsume // 聚合流水数据
  52. jobs[consumeMd.EggPublishDataFunName] = EggPublishDataConsume // 聚合流水数据
  53. jobs[consumeMd.EggRecoverDataFunName] = EggRecoverDataConsume // 聚合流水数据
  54. jobs[consumeMd.EggRestoreDataFunName] = EggRestoreDataConsume // 聚合流水数据
  55. }
  56. func Run() {
  57. for _, v := range consumeMd.RabbitMqQueueKeyList {
  58. if _, ok := jobs[v.ConsumeFunName]; ok {
  59. go doConsume(v.ConsumeFunName, *v)()
  60. }
  61. }
  62. }
  63. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  64. return func() {
  65. begin := time.Now().Local()
  66. jobs[fnName](queue)
  67. end := time.Now().Local()
  68. logx.Infof(
  69. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  70. fnName,
  71. begin.Format("2006-01-02 15:04:05.000"),
  72. end.Format("2006-01-02 15:04:05.000"),
  73. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  74. )
  75. }
  76. }