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.
 
 
 

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