golang 的 rabbitmq 消费项目
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1年前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package cfg
  2. import (
  3. "flag"
  4. "io/ioutil"
  5. "gopkg.in/yaml.v2"
  6. mc "applet/app/utils/cache/cache"
  7. "applet/app/utils/logx"
  8. )
  9. func InitTaskCfg() {
  10. path := flag.String("c", "etc/task.yml", "config file")
  11. flag.Parse()
  12. var (
  13. c []byte
  14. err error
  15. conf *Config
  16. )
  17. if c, err = ioutil.ReadFile(*path); err != nil {
  18. panic(err)
  19. }
  20. if err = yaml.Unmarshal(c, &conf); err != nil {
  21. panic(err)
  22. }
  23. Prd = conf.Prd
  24. Debug = conf.Debug
  25. DB = &conf.DB
  26. DataDB = &conf.DataDB
  27. Log = &conf.Log
  28. Admin = &conf.Admin
  29. RedisAddr = conf.RedisAddr
  30. Local = conf.Local
  31. AppComm = &conf.AppComm
  32. }
  33. var MemCache mc.Cache
  34. func InitMemCache() {
  35. var err error
  36. MemCache, err = mc.NewCache("memory", `{"interval":60}`)
  37. if err != nil {
  38. logx.Fatal(err.Error())
  39. }
  40. }