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

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