Skip to content

Commit

Permalink
Move equality test in the throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
juliens authored and traefiker committed Feb 10, 2020
1 parent e4aaa84 commit c39614d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/server/configurationwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@ func (c *ConfigurationWatcher) listenConfigurations(ctx context.Context) {
func (c *ConfigurationWatcher) loadMessage(configMsg dynamic.Message) {
currentConfigurations := c.currentConfigurations.Get().(dynamic.Configurations)

if reflect.DeepEqual(currentConfigurations[configMsg.ProviderName], configMsg.Configuration) {
logger := log.WithoutContext().WithField(log.ProviderName, configMsg.ProviderName)
logger.Infof("Skipping same configuration for provider %s", configMsg.ProviderName)
return
}

// Copy configurations to new map so we don't change current if LoadConfig fails
newConfigurations := currentConfigurations.DeepCopy()
newConfigurations[configMsg.ProviderName] = configMsg.Configuration
Expand Down Expand Up @@ -210,11 +204,18 @@ func (c *ConfigurationWatcher) throttleProviderConfigReload(ctx context.Context,
}
})

var previousConfig dynamic.Message
for {
select {
case <-ctx.Done():
return
case nextConfig := <-in:
if reflect.DeepEqual(previousConfig, nextConfig) {
logger := log.WithoutContext().WithField(log.ProviderName, nextConfig.ProviderName)
logger.Info("Skipping same configuration")
continue
}
previousConfig = nextConfig
ring.In() <- nextConfig
}
}
Expand Down

0 comments on commit c39614d

Please sign in to comment.