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

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