agollo icon indicating copy to clipboard operation
agollo copied to clipboard

apollo启动的时候必须把所有要用的namespace配置上吗?

Open chowyu12 opened this issue 2 years ago • 3 comments

请简单描述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")

chowyu12 avatar Jun 08 '22 02:06 chowyu12

请简单描述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() 获取。

zouyx avatar Jun 14 '22 06:06 zouyx


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没有接,所以并没有拿到对应的配置

richardJiang avatar Jun 14 '22 09:06 richardJiang

请简单描述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() 获取。

richardJiang avatar Jun 15 '22 09:06 richardJiang

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.

stale[bot] avatar Aug 14 '22 13:08 stale[bot]