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

1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1 vuosi sitten
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.CanalOrderConsumeFunName] = CanalOrderConsume
  17. jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
  18. jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
  19. jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
  20. jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
  21. jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
  22. jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
  23. jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
  24. jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
  25. jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
  26. jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
  27. //jobs[consumeMd.CanalMallOrdForYouMiShangFunName] = CanalMallOrdForYouMiShang
  28. jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore
  29. jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail
  30. jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
  31. jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
  32. jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate
  33. jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
  34. }
  35. func Run() {
  36. for _, v := range consumeMd.RabbitMqQueueKeyList {
  37. if _, ok := jobs[v.ConsumeFunName]; ok {
  38. go doConsume(v.ConsumeFunName, *v)()
  39. }
  40. }
  41. }
  42. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  43. return func() {
  44. begin := time.Now().Local()
  45. jobs[fnName](queue)
  46. end := time.Now().Local()
  47. logx.Infof(
  48. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  49. fnName,
  50. begin.Format("2006-01-02 15:04:05.000"),
  51. end.Format("2006-01-02 15:04:05.000"),
  52. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  53. )
  54. }
  55. }