蛋蛋星球RabbitMq消费项目
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

59 righe
2.5 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.EggEnergyStartLevelDividendFunName] = EggEnergyStartLevelDividendConsume
  17. jobs[consumeMd.EggEnergyDealPlatformRevenueDataFunName] = EggEnergyDealPlatformRevenueDataConsume // 平台营收
  18. jobs[consumeMd.EggEnergyDealFundDataFunName] = EggEnergyDealFundDataConsume // 资金数据
  19. jobs[consumeMd.AliyunSmsRecordFunName] = AliyunSmsRecordConsume //阿里云短信
  20. jobs[consumeMd.JpushRecordFunName] = JpushRecordConsume //极光推送
  21. jobs[consumeMd.AdvertisingSmashConsume] = AdvertisingSmashConsume //砸蛋
  22. jobs[consumeMd.AdvertisingSignConsume] = AdvertisingSignConsume //签到
  23. jobs[consumeMd.EggEnergyDealUserVirtualCoinDataFunName] = EggEnergyDealUserVirtualCoinDataConsume // 视频奖励给相应团队发放积分
  24. jobs[consumeMd.IMEggEnergyBatchSendMessageDataFunName] = IMEggEnergyBatchSendMessageDataConsume // 批量发送信息
  25. jobs[consumeMd.IMEggEnergyDelFriendCircleDataFunName] = IMEggEnergyDelFriendCircleDataConsume // 删除朋友圈
  26. jobs[consumeMd.EggFinWithdrawApplyDataConsumeFunName] = EggFinWithdrawApplyDataConsume // 支付宝打款
  27. jobs[consumeMd.EggEnergySettlementPublicGiveActivityCoinFunName] = EggEnergySettlementPublicGiveActivityCoinConsume
  28. jobs[consumeMd.EggEnergyStartExchangeGreenEnergyFunName] = EggEnergyStartExchangeGreenEnergyConsume
  29. jobs[consumeMd.EggEnergyAutoExchangeGreenEnergyFunName] = EggEnergyAutoExchangeGreenEnergyConsume
  30. jobs[consumeMd.EggEnergyNewUserRegisterDataFunName] = EggEnergyNewUserRegisterDataConsume // 新用户注册
  31. }
  32. func Run() {
  33. for _, v := range consumeMd.RabbitMqQueueKeyList {
  34. if _, ok := jobs[v.ConsumeFunName]; ok {
  35. go doConsume(v.ConsumeFunName, *v)()
  36. }
  37. }
  38. }
  39. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  40. return func() {
  41. begin := time.Now().Local()
  42. jobs[fnName](queue)
  43. end := time.Now().Local()
  44. logx.Infof(
  45. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  46. fnName,
  47. begin.Format("2006-01-02 15:04:05.000"),
  48. end.Format("2006-01-02 15:04:05.000"),
  49. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  50. )
  51. }
  52. }