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.2 KiB

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