Rename BackendsThrottleDuration to ProvidersThrottleDuration
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
2e5f4598f0
commit
a0df7ab921
4 changed files with 23 additions and 24 deletions
|
@ -13,7 +13,7 @@ type GlobalConfiguration struct {
|
||||||
TraefikLogsFile string
|
TraefikLogsFile string
|
||||||
CertFile, KeyFile string
|
CertFile, KeyFile string
|
||||||
LogLevel string
|
LogLevel string
|
||||||
BackendsThrottleDuration time.Duration
|
ProvidersThrottleDuration time.Duration
|
||||||
Docker *DockerProvider
|
Docker *DockerProvider
|
||||||
File *FileProvider
|
File *FileProvider
|
||||||
Web *WebProvider
|
Web *WebProvider
|
||||||
|
@ -30,7 +30,7 @@ func NewGlobalConfiguration() *GlobalConfiguration {
|
||||||
globalConfiguration.Port = ":80"
|
globalConfiguration.Port = ":80"
|
||||||
globalConfiguration.GraceTimeOut = 10
|
globalConfiguration.GraceTimeOut = 10
|
||||||
globalConfiguration.LogLevel = "ERROR"
|
globalConfiguration.LogLevel = "ERROR"
|
||||||
globalConfiguration.BackendsThrottleDuration = time.Duration(2 * time.Second)
|
globalConfiguration.ProvidersThrottleDuration = time.Duration(2 * time.Second)
|
||||||
|
|
||||||
return globalConfiguration
|
return globalConfiguration
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ For example:
|
||||||
# Optional
|
# Optional
|
||||||
# Default: "2s"
|
# Default: "2s"
|
||||||
#
|
#
|
||||||
# BackendsThrottleDuration = "5s"
|
# ProvidersThrottleDuration = "5s"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
11
traefik.go
11
traefik.go
|
@ -104,15 +104,15 @@ func main() {
|
||||||
configMsg := <-configurationChan
|
configMsg := <-configurationChan
|
||||||
log.Infof("Configuration receveived from provider %s: %#v", configMsg.providerName, configMsg.configuration)
|
log.Infof("Configuration receveived from provider %s: %#v", configMsg.providerName, configMsg.configuration)
|
||||||
lastConfigs[configMsg.providerName] = &configMsg
|
lastConfigs[configMsg.providerName] = &configMsg
|
||||||
if time.Now().After(lastReceivedConfiguration.Add(time.Duration(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.BackendsThrottleDuration)
|
log.Infof("Last %s config received more than %s, OK", configMsg.providerName, globalConfiguration.ProvidersThrottleDuration)
|
||||||
// last config received more than n s ago
|
// last config received more than n s ago
|
||||||
configurationChanValidated <- configMsg
|
configurationChanValidated <- configMsg
|
||||||
} else {
|
} 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() {
|
go func() {
|
||||||
<-time.After(globalConfiguration.BackendsThrottleDuration)
|
<-time.After(globalConfiguration.ProvidersThrottleDuration)
|
||||||
if time.Now().After(lastReceivedConfiguration.Add(time.Duration(globalConfiguration.BackendsThrottleDuration))) {
|
if time.Now().After(lastReceivedConfiguration.Add(time.Duration(globalConfiguration.ProvidersThrottleDuration))) {
|
||||||
log.Infof("Waited for %s config, OK", configMsg.providerName)
|
log.Infof("Waited for %s config, OK", configMsg.providerName)
|
||||||
configurationChanValidated <- *lastConfigs[configMsg.providerName]
|
configurationChanValidated <- *lastConfigs[configMsg.providerName]
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,6 @@ func main() {
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
configMsg := <-configurationChanValidated
|
configMsg := <-configurationChanValidated
|
||||||
log.Debugf("Configuration %s", spew.Sdump(configMsg.configuration))
|
|
||||||
if configMsg.configuration == nil {
|
if configMsg.configuration == nil {
|
||||||
log.Info("Skipping empty configuration")
|
log.Info("Skipping empty configuration")
|
||||||
} else if reflect.DeepEqual(currentConfigurations[configMsg.providerName], configMsg.configuration) {
|
} else if reflect.DeepEqual(currentConfigurations[configMsg.providerName], configMsg.configuration) {
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
# Optional
|
# Optional
|
||||||
# Default: "2s"
|
# Default: "2s"
|
||||||
#
|
#
|
||||||
# BackendsThrottleDuration = "5s"
|
# ProvidersThrottleDuration = "5s"
|
||||||
|
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
|
|
Loading…
Reference in a new issue