mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 02:45:42 +03:00
Remove circular dependency
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
"github.com/hashicorp/consul/lib"
|
||||
"github.com/hashicorp/nomad/helper/codec"
|
||||
"github.com/hashicorp/nomad/helper/pool"
|
||||
"github.com/hashicorp/nomad/nomad"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/hashicorp/yamux"
|
||||
)
|
||||
@@ -69,7 +68,7 @@ TRY:
|
||||
|
||||
// We can wait a bit and retry!
|
||||
if time.Since(firstCheck) < c.config.RPCHoldTimeout {
|
||||
jitter := lib.RandomStagger(c.config.RPCHoldTimeout / nomad.JitterFraction)
|
||||
jitter := lib.RandomStagger(c.config.RPCHoldTimeout / structs.JitterFraction)
|
||||
select {
|
||||
case <-time.After(jitter):
|
||||
goto TRY
|
||||
|
||||
10
nomad/rpc.go
10
nomad/rpc.go
@@ -31,12 +31,6 @@ const (
|
||||
// if no time is specified. Previously we would wait the maxQueryTime.
|
||||
defaultQueryTime = 300 * time.Second
|
||||
|
||||
// JitterFraction is a the limit to the amount of jitter we apply
|
||||
// to a user specified MaxQueryTime. We divide the specified time by
|
||||
// the fraction. So 16 == 6.25% limit of jitter. This jitter is also
|
||||
// applied to RPCHoldTimeout.
|
||||
JitterFraction = 16
|
||||
|
||||
// Warn if the Raft command is larger than this.
|
||||
// If it's over 1MB something is probably being abusive.
|
||||
raftWarnSize = 1024 * 1024
|
||||
@@ -279,7 +273,7 @@ CHECK_LEADER:
|
||||
firstCheck = time.Now()
|
||||
}
|
||||
if time.Now().Sub(firstCheck) < s.config.RPCHoldTimeout {
|
||||
jitter := lib.RandomStagger(s.config.RPCHoldTimeout / JitterFraction)
|
||||
jitter := lib.RandomStagger(s.config.RPCHoldTimeout / structs.JitterFraction)
|
||||
select {
|
||||
case <-time.After(jitter):
|
||||
goto CHECK_LEADER
|
||||
@@ -432,7 +426,7 @@ func (s *Server) blockingRPC(opts *blockingOptions) error {
|
||||
}
|
||||
|
||||
// Apply a small amount of jitter to the request
|
||||
opts.queryOpts.MaxQueryTime += lib.RandomStagger(opts.queryOpts.MaxQueryTime / JitterFraction)
|
||||
opts.queryOpts.MaxQueryTime += lib.RandomStagger(opts.queryOpts.MaxQueryTime / structs.JitterFraction)
|
||||
|
||||
// Setup a query timeout
|
||||
ctx, cancel = context.WithTimeout(context.Background(), opts.queryOpts.MaxQueryTime)
|
||||
|
||||
@@ -116,6 +116,12 @@ const (
|
||||
// DefaultNamespace is the default namespace.
|
||||
DefaultNamespace = "default"
|
||||
DefaultNamespaceDescription = "Default shared namespace"
|
||||
|
||||
// JitterFraction is a the limit to the amount of jitter we apply
|
||||
// to a user specified MaxQueryTime. We divide the specified time by
|
||||
// the fraction. So 16 == 6.25% limit of jitter. This jitter is also
|
||||
// applied to RPCHoldTimeout.
|
||||
JitterFraction = 16
|
||||
)
|
||||
|
||||
// Context defines the scope in which a search for Nomad object operates, and
|
||||
|
||||
Reference in New Issue
Block a user