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 3.5 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.ZhiosOrderFreeFunName] = ZhiosOrderFree
  17. jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal
  18. jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond
  19. //
  20. jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal
  21. jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy
  22. jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
  23. //
  24. jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder
  25. jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder
  26. //jobs[consumeMd.ZhiosAppreciationDevFunName] = ZhiosAppreciation
  27. jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
  28. jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
  29. //jobs[consumeMd.ZhiosAcquisitionConditionDevFunName] = ZhiosAcquisitionCondition
  30. jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
  31. jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
  32. jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
  33. jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
  34. jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
  35. jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
  36. jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
  37. jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
  38. jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
  39. jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
  40. jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
  41. jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
  42. jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond
  43. //jobs[consumeMd.CanalMallOrdForYouMiShangFunName] = CanalMallOrdForYouMiShang
  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.ZhiosRechargeOrderFailDevFunName] = ZhiosRechargeOrderFailDev
  53. jobs[consumeMd.CloudIssuanceMsgCallBackFunName] = CloudIssuanceMsgCallBackConsume
  54. }
  55. func Run() {
  56. for _, v := range consumeMd.RabbitMqQueueKeyList {
  57. if _, ok := jobs[v.ConsumeFunName]; ok {
  58. go doConsume(v.ConsumeFunName, *v)()
  59. }
  60. }
  61. }
  62. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  63. return func() {
  64. begin := time.Now().Local()
  65. jobs[fnName](queue)
  66. end := time.Now().Local()
  67. logx.Infof(
  68. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  69. fnName,
  70. begin.Format("2006-01-02 15:04:05.000"),
  71. end.Format("2006-01-02 15:04:05.000"),
  72. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  73. )
  74. }
  75. }