agollo
agollo copied to clipboard
apollo启动的时候必须把所有要用的namespace配置上吗?
请简单描述bug的场景 代码
c := &config.AppConfig{
AppID: "appid",
Cluster: "dev",
IP: "http://xxxxxxx:8080",
NamespaceName: "application",
IsBackupConfig: true,
Secret: "xxxxxx",
}
client, _ := agollo.StartWithConfig(func() (*config.AppConfig, error) {
return c, nil
})
fmt.Println("初始化Apollo配置成功")
// 获取不到namespace为common 的配置,cache ==nil
cache := client.GetConfigCache("common")
请简单描述bug的场景 代码
c := &config.AppConfig{ AppID: "appid", Cluster: "dev", IP: "http://xxxxxxx:8080", NamespaceName: "application", IsBackupConfig: true, Secret: "xxxxxx", } client, _ := agollo.StartWithConfig(func() (*config.AppConfig, error) { return c, nil }) fmt.Println("初始化Apollo配置成功") // 获取不到namespace为common 的配置,cache ==nil cache := client.GetConfigCache("common")
不一定需要,可以通过 client.GetConfigAndInit() 获取。
func (c *Client) GetConfigAndInit(namespace string) *storage.Config {
if namespace == "" {
return nil
}
config := c.cache.GetConfig(namespace)
if config == nil {
//init cache
storage.CreateNamespaceConfig(namespace)
//sync config
syncApolloConfig.SyncWithNamespace(namespace, c.getAppConfig)
}
config = c.cache.GetConfig(namespace)
return config
}
syncApolloConfig.SyncWithNamespace(namespace, c.getAppConfig) 这个方法的response没有接,所以并没有拿到对应的配置
请简单描述bug的场景 代码
c := &config.AppConfig{ AppID: "appid", Cluster: "dev", IP: "http://xxxxxxx:8080", NamespaceName: "application", IsBackupConfig: true, Secret: "xxxxxx", } client, _ := agollo.StartWithConfig(func() (*config.AppConfig, error) { return c, nil }) fmt.Println("初始化Apollo配置成功") // 获取不到namespace为common 的配置,cache ==nil cache := client.GetConfigCache("common")
不一定需要,可以通过 client.GetConfigAndInit() 获取。
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.