golang 的 rabbitmq 消费项目
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

104 linhas
4.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.ZhiosUserUpLvFunName] = ZhiosUserUpLv
  17. jobs[consumeMd.CanalGuideOrderByUserUpLvConsume] = CanalGuideOrderByUserUpLvConsume
  18. jobs[consumeMd.ZhiosOrderFreeFunName] = ZhiosOrderFree
  19. jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal
  20. jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond
  21. //
  22. jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal
  23. jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy
  24. jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
  25. //
  26. jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder
  27. jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder
  28. //jobs[consumeMd.ZhiosAppreciationDevFunName] = ZhiosAppreciation
  29. jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
  30. jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
  31. //jobs[consumeMd.ZhiosAcquisitionConditionDevFunName] = ZhiosAcquisitionCondition
  32. jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
  33. jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
  34. jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
  35. jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
  36. jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
  37. jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
  38. jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
  39. jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
  40. jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
  41. jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
  42. jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
  43. jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
  44. jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond
  45. //jobs[consumeMd.CanalMallOrdForYouMiShangFunName] = CanalMallOrdForYouMiShang
  46. jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore
  47. jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail
  48. jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
  49. jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
  50. jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate
  51. jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
  52. jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
  53. jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward
  54. jobs[consumeMd.ZhiosRechargeOrderFailDevFunName] = ZhiosRechargeOrderFailDev
  55. ////////////////////////////////////// V1 /////////////////////////////////////////////////////
  56. //jobs[consumeMd.CloudIssuanceMsgCallBackFunName] = CloudIssuanceMsgCallBackConsume
  57. //////////////////////////////////////// V2 /////////////////////////////////////////////////////
  58. //jobs[consumeMd.SupplyCloudChainFenxiaoNewChangeFunName] = SupplyCloudChainFenxiaoNewChangeConsume
  59. //////////////////////////////////////// V3 /////////////////////////////////////////////////////
  60. //jobs[consumeMd.MallAddSupplyGoodsFunName] = MallAddSupplyGoodsConsume
  61. }
  62. func Run() {
  63. for _, v := range consumeMd.RabbitMqQueueKeyList {
  64. if _, ok := jobs[v.ConsumeFunName]; ok {
  65. go doConsume(v.ConsumeFunName, *v)()
  66. }
  67. }
  68. }
  69. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  70. return func() {
  71. begin := time.Now().Local()
  72. jobs[fnName](queue)
  73. end := time.Now().Local()
  74. logx.Infof(
  75. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  76. fnName,
  77. begin.Format("2006-01-02 15:04:05.000"),
  78. end.Format("2006-01-02 15:04:05.000"),
  79. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  80. )
  81. }
  82. }