No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

configure_config.go 951B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package subconfigs
  2. import (
  3. "fmt"
  4. "git.x2erp.com/qdy/go-base/config/core"
  5. )
  6. // ConfigureConfig 配置中心配置
  7. type ConfigureConfig struct {
  8. core.BaseConfig
  9. Url string `yaml:"url" desc:"配置中心地址"`
  10. Token string `yaml:"token" desc:"访问配置中心的token"`
  11. }
  12. func (c *ConfigureConfig) Description() string {
  13. return "configure访问配置中心的配置"
  14. }
  15. func NewConfgigureConfig() *ConfigureConfig {
  16. return &ConfigureConfig{}
  17. }
  18. func (c *ConfigureConfig) SetDefaults() {
  19. c.Url = "http://localhost:8080"
  20. c.Token = "123"
  21. }
  22. func (c *ConfigureConfig) Load(data map[string]interface{}) error {
  23. return c.LoadFromYAML(data, c)
  24. }
  25. func (c *ConfigureConfig) Validate() error {
  26. if c.Url == "" {
  27. return fmt.Errorf("configure center url must be positive")
  28. }
  29. return nil
  30. }
  31. func (c *ConfigureConfig) IsConfigured() bool {
  32. return c.Url != ""
  33. }
  34. // 自动注册
  35. func init() {
  36. core.Register("configure", &ConfigureConfig{})
  37. }