蛋蛋星球RabbitMq消费项目
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

init.go 3.7 KiB

hace 1 mes
hace 1 semana
hace 1 semana
hace 1 semana
hace 1 semana
hace 1 mes
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. }
  43. func Run() {
  44. for _, v := range consumeMd.RabbitMqQueueKeyList {
  45. if _, ok := jobs[v.ConsumeFunName]; ok {
  46. go doConsume(v.ConsumeFunName, *v)()
  47. }
  48. }
  49. }
  50. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  51. return func() {
  52. begin := time.Now().Local()
  53. jobs[fnName](queue)
  54. end := time.Now().Local()
  55. logx.Infof(
  56. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  57. fnName,
  58. begin.Format("2006-01-02 15:04:05.000"),
  59. end.Format("2006-01-02 15:04:05.000"),
  60. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  61. )
  62. }
  63. }