Rename BackendsThrottleDuration to ProvidersThrottleDuration

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2015-10-17 14:14:20 +02:00
parent 2e5f4598f0
commit a0df7ab921
4 changed files with 23 additions and 24 deletions

View file

@ -13,7 +13,7 @@ type GlobalConfiguration struct {
TraefikLogsFile string
CertFile, KeyFile string
LogLevel string
BackendsThrottleDuration time.Duration
ProvidersThrottleDuration time.Duration
Docker *DockerProvider
File *FileProvider
Web *WebProvider
@ -30,7 +30,7 @@ func NewGlobalConfiguration() *GlobalConfiguration {
globalConfiguration.Port = ":80"
globalConfiguration.GraceTimeOut = 10
globalConfiguration.LogLevel = "ERROR"
globalConfiguration.BackendsThrottleDuration = time.Duration(2 * time.Second)
globalConfiguration.ProvidersThrottleDuration = time.Duration(2 * time.Second)
return globalConfiguration
}

View file

@ -115,7 +115,7 @@ For example:
# Optional
# Default: "2s"
#
# BackendsThrottleDuration = "5s"
# ProvidersThrottleDuration = "5s"
```

View file

@ -104,15 +104,15 @@ func main() {
configMsg := <-configurationChan
log.Infof("Configuration receveived from provider %s: %#v", configMsg.providerName, configMsg.configuration)
lastConfigs[configMsg.providerName] = &configMsg
if time.Now().After(lastReceivedConfiguration.Add(time.Duration(globalConfiguration.BackendsThrottleDuration))) {
log.Infof("Last %s config received more than %s, OK", configMsg.providerName, globalConfiguration.BackendsThrottleDuration)
if time.Now().After(lastReceivedConfiguration.Add(time.Duration(globalConfiguration.ProvidersThrottleDuration))) {
log.Infof("Last %s config received more than %s, OK", configMsg.providerName, globalConfiguration.ProvidersThrottleDuration)
// last config received more than n s ago
configurationChanValidated <- configMsg
} else {
log.Infof("Last %s config received less than %s, waiting...", configMsg.providerName, globalConfiguration.BackendsThrottleDuration)
log.Infof("Last %s config received less than %s, waiting...", configMsg.providerName, globalConfiguration.ProvidersThrottleDuration)
go func() {
<-time.After(globalConfiguration.BackendsThrottleDuration)
if time.Now().After(lastReceivedConfiguration.Add(time.Duration(globalConfiguration.BackendsThrottleDuration))) {
<-time.After(globalConfiguration.ProvidersThrottleDuration)
if time.Now().After(lastReceivedConfiguration.Add(time.Duration(globalConfiguration.ProvidersThrottleDuration))) {
log.Infof("Waited for %s config, OK", configMsg.providerName)
configurationChanValidated <- *lastConfigs[configMsg.providerName]
}
@ -124,7 +124,6 @@ func main() {
go func() {
for {
configMsg := <-configurationChanValidated
log.Debugf("Configuration %s", spew.Sdump(configMsg.configuration))
if configMsg.configuration == nil {
log.Info("Skipping empty configuration")
} else if reflect.DeepEqual(currentConfigurations[configMsg.providerName], configMsg.configuration) {

View file

@ -51,7 +51,7 @@
# Optional
# Default: "2s"
#
# BackendsThrottleDuration = "5s"
# ProvidersThrottleDuration = "5s"
################################################################