feat: initial release
This commit is contained in:
parent
a3cf21f5bd
commit
761174d035
41 changed files with 2008 additions and 217 deletions
47
internal/config/master.go
Normal file
47
internal/config/master.go
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package config
|
||||
|
||||
import "errors"
|
||||
|
||||
type MasterConfig struct {
|
||||
ObserverInterval int `toml:"observer_interval"`
|
||||
|
||||
BackoffSeconds int `toml:"backoff_seconds"`
|
||||
BackoffCount int `toml:"backoff_count"`
|
||||
|
||||
baseRoleConfig
|
||||
}
|
||||
|
||||
func (c MasterConfig) Validate() error {
|
||||
if c.ObserverInterval < 1 {
|
||||
return errors.New("invalid observer_interval")
|
||||
}
|
||||
|
||||
if c.BackoffSeconds < 1 {
|
||||
return errors.New("invalid backoff_seconds")
|
||||
}
|
||||
|
||||
if c.BackoffCount < 1 {
|
||||
return errors.New("invalid backoff_count")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *MasterConfig) Merge(other MasterConfig) {
|
||||
if other.set {
|
||||
c.set = true
|
||||
}
|
||||
|
||||
if other.ObserverInterval != 0 {
|
||||
c.ObserverInterval = other.ObserverInterval
|
||||
}
|
||||
|
||||
if other.BackoffSeconds != 0 {
|
||||
c.BackoffSeconds = other.BackoffSeconds
|
||||
}
|
||||
|
||||
if other.BackoffCount != 0 {
|
||||
c.BackoffCount = other.BackoffCount
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue