conf.go 976 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package conf
  2. import (
  3. ecode "go-common/library/ecode/tip"
  4. "go-common/library/log"
  5. "go-common/library/naming/discovery"
  6. bm "go-common/library/net/http/blademaster"
  7. "go-common/library/net/rpc/warden"
  8. "go-common/library/queue/databus"
  9. xtime "go-common/library/time"
  10. "github.com/BurntSushi/toml"
  11. )
  12. var (
  13. // Conf config
  14. Conf = &Config{}
  15. )
  16. // Config .
  17. type Config struct {
  18. Log *log.Config
  19. Ecode *ecode.Config
  20. HTTP *bm.ServerConfig
  21. RPC *warden.ClientConfig
  22. Databus *databus.Config
  23. Discovery *discovery.Config
  24. Routine *Routine
  25. Room *Room
  26. }
  27. // Routine routine.
  28. type Routine struct {
  29. Size uint64
  30. Chan uint64
  31. }
  32. // Room room.
  33. type Room struct {
  34. Refresh xtime.Duration
  35. Idle xtime.Duration
  36. Batch int
  37. Signal xtime.Duration
  38. Compress bool
  39. }
  40. // Set set config and decode.
  41. func (c *Config) Set(text string) error {
  42. var tmp Config
  43. if _, err := toml.Decode(text, &tmp); err != nil {
  44. return err
  45. }
  46. *c = tmp
  47. return nil
  48. }