Plumb config

This commit is contained in:
Alex Dadgar 2018-01-10 11:28:44 -08:00
parent 05c4fe8675
commit e03b074650
2 changed files with 9 additions and 3 deletions

View File

@ -195,6 +195,13 @@ type Config struct {
// BackwardsCompatibleMetrics determines whether to show methods of // BackwardsCompatibleMetrics determines whether to show methods of
// displaying metrics for older verions, or to only show the new format // displaying metrics for older verions, or to only show the new format
BackwardsCompatibleMetrics bool BackwardsCompatibleMetrics bool
// RPCHoldTimeout is how long an RPC can be "held" before it is errored.
// This is used to paper over a loss of leadership by instead holding RPCs,
// so that the caller experiences a slow response rather than an error.
// This period is meant to be long enough for a leader election to take
// place, and a small jitter is applied to avoid a thundering herd.
RPCHoldTimeout time.Duration
} }
func (c *Config) Copy() *Config { func (c *Config) Copy() *Config {
@ -228,6 +235,7 @@ func DefaultConfig() *Config {
NoHostUUID: true, NoHostUUID: true,
DisableTaggedMetrics: false, DisableTaggedMetrics: false,
BackwardsCompatibleMetrics: false, BackwardsCompatibleMetrics: false,
RPCHoldTimeout: 5 * time.Second,
} }
} }

View File

@ -68,9 +68,7 @@ TRY:
} }
// We can wait a bit and retry! // We can wait a bit and retry!
// TODO(alexdadgar): Plumb through the RPCHoldTimeout config if time.Since(firstCheck) < c.config.RPCHoldTimeout {
//if time.Since(firstCheck) < c.config.RPCHoldTimeout {
if time.Since(firstCheck) < 5*time.Second {
jitter := lib.RandomStagger(5 * time.Second / nomad.JitterFraction) jitter := lib.RandomStagger(5 * time.Second / nomad.JitterFraction)
select { select {
case <-time.After(jitter): case <-time.After(jitter):