tidb_conf.go 740 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package conf
  2. import (
  3. "fmt"
  4. xtime "go-common/library/time"
  5. "github.com/BurntSushi/toml"
  6. )
  7. // TiDBInsConf tidb instance config
  8. type TiDBInsConf struct {
  9. Name string
  10. ClusterID string
  11. Addrs []string
  12. Offset int64
  13. CommitTS int64
  14. MonitorPeriod xtime.Duration `toml:"monitor_period"`
  15. Databases []*Database `toml:"db"`
  16. }
  17. func newTiDBConf(fn, fc string) (c *TiDBInsConf, err error) {
  18. var ic struct {
  19. InsConf *TiDBInsConf `toml:"instance"`
  20. }
  21. if _, err = toml.Decode(fc, &ic); err != nil {
  22. return
  23. }
  24. if ic.InsConf == nil {
  25. err = fmt.Errorf("file(%s) cannot decode toml", fn)
  26. return
  27. }
  28. return ic.InsConf, nil
  29. }
  30. // TiDBEvent .
  31. func TiDBEvent() chan *TiDBInsConf {
  32. return tidbEvent
  33. }