Skip to content

Commit c547eef

Browse files
authored
Merge pull request #54 from ShineJstar/ShineJstar-patch-updateAgolloMapKey
Shine jstar patch update agollo map key
2 parents 673e427 + e31fa5c commit c547eef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

viper-remote/remote.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var (
1919
_ viperConfigManager = apolloConfigManager{}
2020
// getConfigManager方法每次返回新对象导致缓存无效,
2121
// 这里通过endpoint作为key复一个对象
22-
// key: endpoint value: agollo.Agollo
22+
// key: endpoint+appid value: agollo.Agollo
2323
agolloMap sync.Map
2424
)
2525

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

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

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

9292
return ag, nil
9393
}

0 commit comments

Comments
 (0)