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
|
@ -7,21 +7,21 @@ import (
|
|||
)
|
||||
|
||||
type GlobalConfiguration struct {
|
||||
Port string
|
||||
GraceTimeOut int64
|
||||
AccessLogsFile string
|
||||
TraefikLogsFile string
|
||||
CertFile, KeyFile string
|
||||
LogLevel string
|
||||
BackendsThrottleDuration time.Duration
|
||||
Docker *DockerProvider
|
||||
File *FileProvider
|
||||
Web *WebProvider
|
||||
Marathon *MarathonProvider
|
||||
Consul *ConsulProvider
|
||||
Etcd *EtcdProvider
|
||||
Zookeeper *ZookepperProvider
|
||||
Boltdb *BoltDbProvider
|
||||
Port string
|
||||
GraceTimeOut int64
|
||||
AccessLogsFile string
|
||||
TraefikLogsFile string
|
||||
CertFile, KeyFile string
|
||||
LogLevel string
|
||||
ProvidersThrottleDuration time.Duration
|
||||
Docker *DockerProvider
|
||||
File *FileProvider
|
||||
Web *WebProvider
|
||||
Marathon *MarathonProvider
|
||||
Consul *ConsulProvider
|
||||
Etcd *EtcdProvider
|
||||
Zookeeper *ZookepperProvider
|
||||
Boltdb *BoltDbProvider
|
||||
}
|
||||
|
||||
func NewGlobalConfiguration() *GlobalConfiguration {
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ For example:
|
|||
# Optional
|
||||
# Default: "2s"
|
||||
#
|
||||
# BackendsThrottleDuration = "5s"
|
||||
# ProvidersThrottleDuration = "5s"
|
||||
|
||||
```
|
||||
|
||||
|
|
11
traefik.go
11
traefik.go
|
@ -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) {
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
# Optional
|
||||
# Default: "2s"
|
||||
#
|
||||
# BackendsThrottleDuration = "5s"
|
||||
# ProvidersThrottleDuration = "5s"
|
||||
|
||||
|
||||
################################################################
|
||||
|
|
Loading…
Reference in a new issue