mirror of https://github.com/status-im/consul.git
agent: Adding new CheckUpdateInterval config
This commit is contained in:
parent
0f7792bc27
commit
971d093283
|
@ -173,6 +173,14 @@ type Config struct {
|
|||
// true, we ignore the leave, and rejoin the cluster on start.
|
||||
RejoinAfterLeave bool `mapstructure:"rejoin_after_leave"`
|
||||
|
||||
// CheckUpdateInterval controls the interval on which the output of a health check
|
||||
// is updated if there is no change to the state. For example, a check in a steady
|
||||
// state may run every 5 second generating a unique output (timestamp, etc), forcing
|
||||
// constant writes. This allows Consul to defer the write for some period of time,
|
||||
// reducing the write pressure when the state is steady.
|
||||
CheckUpdateInterval time.Duration `mapstructure:"-"`
|
||||
CheckUpdateIntervalRaw string `mapstructure:"check_update_interval" json:"-"`
|
||||
|
||||
// AEInterval controls the anti-entropy interval. This is how often
|
||||
// the agent attempts to reconcile it's local state with the server'
|
||||
// representation of our state. Defaults to every 60s.
|
||||
|
@ -221,6 +229,7 @@ func DefaultConfig() *Config {
|
|||
MaxStale: 5 * time.Second,
|
||||
},
|
||||
Protocol: consul.ProtocolVersionMax,
|
||||
CheckUpdateInterval: 5 * time.Minute,
|
||||
AEInterval: time.Minute,
|
||||
}
|
||||
}
|
||||
|
@ -309,6 +318,14 @@ func DecodeConfig(r io.Reader) (*Config, error) {
|
|||
}
|
||||
}
|
||||
|
||||
if raw := result.CheckUpdateIntervalRaw; raw != "" {
|
||||
dur, err := time.ParseDuration(raw)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("CheckUpdateInterval invalid: %v", err)
|
||||
}
|
||||
result.CheckUpdateInterval = dur
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
|
@ -536,6 +553,9 @@ func MergeConfig(a, b *Config) *Config {
|
|||
if b.DNSConfig.MaxStale != 0 {
|
||||
result.DNSConfig.MaxStale = b.DNSConfig.MaxStale
|
||||
}
|
||||
if b.CheckUpdateInterval != 0 {
|
||||
result.CheckUpdateInterval = b.CheckUpdateInterval
|
||||
}
|
||||
|
||||
// Copy the start join addresses
|
||||
result.StartJoin = make([]string, 0, len(a.StartJoin)+len(b.StartJoin))
|
||||
|
|
|
@ -324,6 +324,17 @@ func TestDecodeConfig(t *testing.T) {
|
|||
if config.DNSConfig.ServiceTTL["web"] != 30*time.Second {
|
||||
t.Fatalf("bad: %#v", config)
|
||||
}
|
||||
|
||||
// CheckUpdateInterval
|
||||
input = `{"check_update_interval": "10m"}`
|
||||
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if config.CheckUpdateInterval != 10*time.Minute {
|
||||
t.Fatalf("bad: %#v", config)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeConfig_Service(t *testing.T) {
|
||||
|
@ -466,6 +477,7 @@ func TestMergeConfig(t *testing.T) {
|
|||
UiDir: "/opt/consul-ui",
|
||||
EnableSyslog: true,
|
||||
RejoinAfterLeave: true,
|
||||
CheckUpdateInterval: 8 * time.Minute,
|
||||
}
|
||||
|
||||
c := MergeConfig(a, b)
|
||||
|
|
Loading…
Reference in New Issue