蛋蛋星球RabbitMq消费项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

58 lines
2.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.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. }
  31. func Run() {
  32. for _, v := range consumeMd.RabbitMqQueueKeyList {
  33. if _, ok := jobs[v.ConsumeFunName]; ok {
  34. go doConsume(v.ConsumeFunName, *v)()
  35. }
  36. }
  37. }
  38. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  39. return func() {
  40. begin := time.Now().Local()
  41. jobs[fnName](queue)
  42. end := time.Now().Local()
  43. logx.Infof(
  44. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  45. fnName,
  46. begin.Format("2006-01-02 15:04:05.000"),
  47. end.Format("2006-01-02 15:04:05.000"),
  48. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  49. )
  50. }
  51. }