| 93 | } |
| 94 | |
| 95 | func (c *Config) Validate() error { |
| 96 | if c.Controller.FailOver.MaxPingCount < 3 { |
| 97 | return errors.New("max ping count required >= 3") |
| 98 | } |
| 99 | if c.Controller.FailOver.PingIntervalSeconds < 1 { |
| 100 | return errors.New("ping interval required >= 1s") |
| 101 | } |
| 102 | hostPort := strings.Split(c.Addr, ":") |
| 103 | if hostPort[0] == "0.0.0.0" || hostPort[0] == "127.0.0.1" { |
| 104 | logger.Get().Warn("Leader forward may not work if the host is " + hostPort[0]) |
| 105 | } |
| 106 | return nil |
| 107 | } |
| 108 | |
| 109 | func (c *Config) getAddr() string { |
| 110 | // env has higher priority than configuration. |