golang 的 rabbitmq 消费项目
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

init.go 4.0 KiB

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