conf.go 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package conf
  2. import (
  3. "flag"
  4. "go-common/library/cache/redis"
  5. "go-common/library/database/orm"
  6. "go-common/library/database/sql"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. "go-common/library/net/http/blademaster/middleware/antispam"
  10. v "go-common/library/net/http/blademaster/middleware/verify"
  11. "go-common/library/net/rpc"
  12. "go-common/library/time"
  13. "github.com/BurntSushi/toml"
  14. )
  15. var (
  16. confPath string
  17. // Conf init config
  18. Conf *Config
  19. )
  20. // Config config.
  21. type Config struct {
  22. // log
  23. Log *log.Config
  24. //rpc server2
  25. RPCServer *rpc.ServerConfig
  26. // db
  27. DB *sql.Config
  28. // redis
  29. Redis *redis.Config
  30. // timeout
  31. PollTimeout time.Duration
  32. // local cache
  33. PathCache string
  34. // orm
  35. ORM *orm.Config
  36. //BM
  37. BM *bm.ServerConfig
  38. // Antispam
  39. Antispam *antispam.Config
  40. Verify *v.Config
  41. }
  42. func init() {
  43. flag.StringVar(&confPath, "conf", "./config-service-example.toml", "config path")
  44. }
  45. // Init init.
  46. func Init() (err error) {
  47. _, err = toml.DecodeFile(confPath, &Conf)
  48. return
  49. }