sven.go 396 B

12345678910111213141516171819202122232425262728
  1. package configcenter
  2. import (
  3. "go-common/library/log"
  4. "go-common/library/conf"
  5. )
  6. var (
  7. // Conf conf
  8. Client *conf.Client
  9. Version int
  10. )
  11. func InitConfigCenter() {
  12. var err error
  13. if Client, err = conf.New(); err != nil {
  14. panic(err)
  15. }
  16. // watch update and update Version
  17. Client.WatchAll()
  18. go func() {
  19. for range Client.Event() {
  20. log.Info("config reload")
  21. Version += 1
  22. }
  23. }()
  24. }