mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
[17449] Introduces a locking mechanism over variables (#18207)
It includes the work over the state store, the PRC server, the HTTP server, the go API package and the CLI's command. To read more on the actuall functionality, refer to the RFCs [NMD-178] Locking with Nomad Variables and [NMD-179] Leader election using locking mechanism for the Autoscaler.
This commit is contained in:
committed by
GitHub
parent
86d2cdcf80
commit
72acaf6623
39
api/api.go
39
api/api.go
@@ -12,6 +12,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -200,6 +201,10 @@ type Config struct {
|
||||
TLSConfig *TLSConfig
|
||||
|
||||
Headers http.Header
|
||||
|
||||
// retryOptions holds the configuration necessary to perform retries
|
||||
// on put calls.
|
||||
retryOptions *retryOptions
|
||||
}
|
||||
|
||||
// ClientConfig copies the configuration with a new client address, region, and
|
||||
@@ -578,6 +583,40 @@ func (c *Client) SetSecretID(secretID string) {
|
||||
c.config.SecretID = secretID
|
||||
}
|
||||
|
||||
func (c *Client) configureRetries(ro *retryOptions) {
|
||||
|
||||
c.config.retryOptions = &retryOptions{
|
||||
maxRetries: defaultNumberOfRetries,
|
||||
maxBackoffDelay: defaultMaxBackoffDelay,
|
||||
delayBase: defaultDelayTimeBase,
|
||||
}
|
||||
|
||||
if ro.delayBase != 0 {
|
||||
c.config.retryOptions.delayBase = ro.delayBase
|
||||
}
|
||||
|
||||
if ro.maxRetries != defaultNumberOfRetries {
|
||||
c.config.retryOptions.maxRetries = ro.maxRetries
|
||||
}
|
||||
|
||||
if ro.maxBackoffDelay != 0 {
|
||||
c.config.retryOptions.maxBackoffDelay = ro.maxBackoffDelay
|
||||
}
|
||||
|
||||
if ro.maxToLastCall != 0 {
|
||||
c.config.retryOptions.maxToLastCall = ro.maxToLastCall
|
||||
}
|
||||
|
||||
if ro.fixedDelay != 0 {
|
||||
c.config.retryOptions.fixedDelay = ro.fixedDelay
|
||||
}
|
||||
|
||||
// Ensure that a big attempt number or a big delayBase number will not cause
|
||||
// a negative delay by overflowing the delay increase.
|
||||
c.config.retryOptions.maxValidAttempt = int64(math.Log2(float64(math.MaxInt64 /
|
||||
c.config.retryOptions.delayBase.Nanoseconds())))
|
||||
}
|
||||
|
||||
// request is used to help build up a request
|
||||
type request struct {
|
||||
config *Config
|
||||
|
||||
Reference in New Issue
Block a user