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