Skip to content

Commit

Permalink
Merge pull request apolloconfig#17 from Adol1111/fix_change_event
Browse files Browse the repository at this point in the history
fix: 当key的value没有变化时,不推送这个key的事件通知
  • Loading branch information
zouyx committed Dec 19, 2017
2 parents 24cec8d + c13ee87 commit 6e914bf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ func updateApolloConfig(apolloConfig *ApolloConfig) {
//get change list
changeList := updateApolloConfigCache(apolloConfig.Configurations, configCacheExpireTime)

//create config change event base on change list
event := createConfigChangeEvent(changeList, apolloConfig.NamespaceName)
if len(changeList) > 0 {
//create config change event base on change list
event := createConfigChangeEvent(changeList, apolloConfig.NamespaceName)

//push change event to channel
pushChangeEvent(event)
//push change event to channel
pushChangeEvent(event)
}

//update apollo connection config

Expand Down Expand Up @@ -67,7 +69,9 @@ func updateApolloConfigCache(configurations map[string]string,expireTime int) ma
} else {
//update
oldValue, _ := apolloConfigCache.Get([]byte(key))
changes[key] = createModifyConfigChange(string(oldValue), value)
if string(oldValue) != value {
changes[key] = createModifyConfigChange(string(oldValue), value)
}
}

apolloConfigCache.Set([]byte(key), []byte(value), expireTime)
Expand Down

0 comments on commit 6e914bf

Please sign in to comment.