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

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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
  17. //
  18. jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder
  19. jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder
  20. //jobs[consumeMd.ZhiosAppreciationDevFunName] = ZhiosAppreciation
  21. jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
  22. jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
  23. //jobs[consumeMd.ZhiosAcquisitionConditionDevFunName] = ZhiosAcquisitionCondition
  24. jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
  25. jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
  26. jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
  27. jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
  28. jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
  29. jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
  30. jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
  31. jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
  32. jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
  33. jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
  34. jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
  35. jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
  36. jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond
  37. //jobs[consumeMd.CanalMallOrdForYouMiShangFunName] = CanalMallOrdForYouMiShang
  38. jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore
  39. jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail
  40. jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
  41. jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
  42. jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate
  43. jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
  44. jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
  45. jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward
  46. //jobs[consumeMd.ZhiosRechargeOrderFailDevFunName] = ZhiosRechargeOrderFailDev
  47. }
  48. func Run() {
  49. for _, v := range consumeMd.RabbitMqQueueKeyList {
  50. if _, ok := jobs[v.ConsumeFunName]; ok {
  51. go doConsume(v.ConsumeFunName, *v)()
  52. }
  53. }
  54. }
  55. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  56. return func() {
  57. begin := time.Now().Local()
  58. jobs[fnName](queue)
  59. end := time.Now().Local()
  60. logx.Infof(
  61. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  62. fnName,
  63. begin.Format("2006-01-02 15:04:05.000"),
  64. end.Format("2006-01-02 15:04:05.000"),
  65. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  66. )
  67. }
  68. }