Skip to content

Commit

Permalink
Merge 34372fc into ce67ae8
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyx committed May 4, 2021
2 parents ce67ae8 + 34372fc commit ae0bc19
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func StartWithConfig(loadAppConfig func() (*config.AppConfig, error)) (*Client,
configs := syncApolloConfig.Sync(c.getAppConfig)
if len(configs) > 0 {
for _, apolloConfig := range configs {
c.cache.UpdateApolloConfig(apolloConfig, c.getAppConfig, true)
c.cache.UpdateApolloConfig(apolloConfig, c.getAppConfig)
}
}

Expand Down
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func TestAutoSyncConfigServicesNormal2NotModified(t *testing.T) {
apolloConfig, _ := createApolloConfigWithJSON([]byte(configResponseStr))
client.cache.UpdateApolloConfig(apolloConfig.(*config.ApolloConfig), func() config.AppConfig {
return *newAppConfig
}, true)
})

config := newAppConfig.GetCurrentApolloConfig().Get()[newAppConfig.NamespaceName]

Expand Down
2 changes: 1 addition & 1 deletion component/notify/componet_notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (c *ConfigComponent) Start() {
case <-t2.C:
configs := instance.Sync(c.appConfigFunc)
for _, apolloConfig := range configs {
c.cache.UpdateApolloConfig(apolloConfig, c.appConfigFunc, true)
c.cache.UpdateApolloConfig(apolloConfig, c.appConfigFunc)
}
t2.Reset(longPollInterval)
}
Expand Down
4 changes: 2 additions & 2 deletions storage/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (c *Config) GetBoolValue(key string, defaultValue bool) bool {

//UpdateApolloConfig 根据config server返回的内容更新内存
//并判断是否需要写备份文件
func (c *Cache) UpdateApolloConfig(apolloConfig *config.ApolloConfig, appConfigFunc func() config.AppConfig, isBackupConfig bool) {
func (c *Cache) UpdateApolloConfig(apolloConfig *config.ApolloConfig, appConfigFunc func() config.AppConfig) {
if apolloConfig == nil {
log.Error("apolloConfig is null,can't update!")
return
Expand All @@ -246,7 +246,7 @@ func (c *Cache) UpdateApolloConfig(apolloConfig *config.ApolloConfig, appConfigF
c.pushChangeEvent(event)
}

if isBackupConfig {
if appConfig.GetIsBackupConfig() {
//write config file async
apolloConfig.AppID = appConfig.AppID
go extension.GetFileHandler().WriteConfigFile(apolloConfig, appConfig.GetBackupConfigPath())
Expand Down
4 changes: 2 additions & 2 deletions storage/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func creatTestApolloConfig(configurations map[string]interface{}, namespace stri
apolloConfig.Configurations = configurations
c.UpdateApolloConfig(apolloConfig, func() config.AppConfig {
return *appConfig
}, true)
})
return c

}
Expand All @@ -75,7 +75,7 @@ func TestUpdateApolloConfigNull(t *testing.T) {
apolloConfig.Configurations = configurations
c.UpdateApolloConfig(apolloConfig, func() config.AppConfig {
return *appConfig
}, true)
})

currentConnApolloConfig := appConfig.GetCurrentApolloConfig().Get()
config := currentConnApolloConfig[defaultNamespace]
Expand Down

0 comments on commit ae0bc19

Please sign in to comment.