golang 的 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.

init.go 4.0 KiB

11 months ago
11 months ago
11 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. //
  29. ////jobs[consumeMd.ZhiosAppreciationDevFunName] = ZhiosAppreciation
  30. //
  31. //jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
  32. //jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
  33. //
  34. ////jobs[consumeMd.ZhiosAcquisitionConditionDevFunName] = ZhiosAcquisitionCondition
  35. //
  36. //jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
  37. //jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
  38. //jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
  39. //jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
  40. //
  41. //jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
  42. //jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
  43. //jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
  44. //jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
  45. //jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
  46. //
  47. //jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
  48. //jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
  49. //jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
  50. //jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond
  51. //
  52. ////jobs[consumeMd.CanalMallOrdForYouMiShangFunName] = CanalMallOrdForYouMiShang
  53. //jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore
  54. //
  55. //jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail
  56. //
  57. //jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
  58. //jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
  59. //jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate
  60. //
  61. //jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
  62. //jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
  63. //jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward
  64. //
  65. ////jobs[consumeMd.ZhiosRechargeOrderFailDevFunName] = ZhiosRechargeOrderFailDev
  66. ////////////////////////////////////// V1 /////////////////////////////////////////////////////
  67. jobs[consumeMd.CloudIssuanceMsgCallBackFunName] = CloudIssuanceMsgCallBackConsume
  68. //////////////////////////////////////// V2 /////////////////////////////////////////////////////
  69. //jobs[consumeMd.SupplyCloudChainFenxiaoNewChangeFunName] = SupplyCloudChainFenxiaoNewChangeConsume
  70. }
  71. func Run() {
  72. for _, v := range consumeMd.RabbitMqQueueKeyList {
  73. if _, ok := jobs[v.ConsumeFunName]; ok {
  74. go doConsume(v.ConsumeFunName, *v)()
  75. }
  76. }
  77. }
  78. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  79. return func() {
  80. begin := time.Now().Local()
  81. jobs[fnName](queue)
  82. end := time.Now().Local()
  83. logx.Infof(
  84. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  85. fnName,
  86. begin.Format("2006-01-02 15:04:05.000"),
  87. end.Format("2006-01-02 15:04:05.000"),
  88. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  89. )
  90. }
  91. }