Skip to content

Commit

Permalink
Merge pull request #54 from ShineJstar/ShineJstar-patch-updateAgolloM…
Browse files Browse the repository at this point in the history
…apKey

Shine jstar patch update agollo map key
  • Loading branch information
shima-park authored Dec 11, 2020
2 parents 673e427 + e31fa5c commit c547eef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions viper-remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
_ viperConfigManager = apolloConfigManager{}
// getConfigManager方法每次返回新对象导致缓存无效,
// 这里通过endpoint作为key复一个对象
// key: endpoint value: agollo.Agollo
// key: endpoint+appid value: agollo.Agollo
agolloMap sync.Map
)

Expand Down Expand Up @@ -73,7 +73,7 @@ func newApolloConfigManager(appid, endpoint string, opts []agollo.Option) (*apol
}

func newAgollo(appid, endpoint string, opts []agollo.Option) (agollo.Agollo, error) {
i, found := agolloMap.Load(endpoint)
i, found := agolloMap.Load(endpoint + "/" + appid)
if !found {
ag, err := agollo.New(
endpoint,
Expand All @@ -87,7 +87,7 @@ func newAgollo(appid, endpoint string, opts []agollo.Option) (agollo.Agollo, err
// 监听并同步apollo配置
ag.Start()

agolloMap.Store(endpoint, ag)
agolloMap.Store(endpoint + "/" + appid, ag)

return ag, nil
}
Expand Down

0 comments on commit c547eef

Please sign in to comment.