Giter Site home page Giter Site logo

Comments (20)

eddycjy avatar eddycjy commented on August 17, 2024

@zouyx 请问有什么解决方案或者问题出在了哪里?

from agollo.

zouyx avatar zouyx commented on August 17, 2024

@eddycjy 是否能提供一下你是使用哪种start方式?有调用过InitCustomConfig?还是直接读取properties?

from agollo.

eddycjy avatar eddycjy commented on August 17, 2024

@zouyx 感谢回复。我们这边正在接入,但遇到了这问题,start 方式如下:

func (a *Apollo) StartWithLogger(loggerInterface agollo.LoggerInterface) error {
	agollo.InitCustomConfig(func() (*agollo.AppConfig, error) {
		return a.AppConfig,nil
	})

	return agollo.StartWithLogger(loggerInterface)
}

有调用 InitCustomConfig

from agollo.

zouyx avatar zouyx commented on August 17, 2024

@eddycjy 明白,尽量会今天内定位并解决

from agollo.

eddycjy avatar eddycjy commented on August 17, 2024

@eddycjy 明白,尽量会今天内定位并解决

好的感谢,另外当执行这个动作后。应用根目录会出现 apolloConfig.json 文件...我看了下,似乎也没有地方可以禁止其生成这个文件

from agollo.

zouyx avatar zouyx commented on August 17, 2024

@eddycjy 这个文件原意是用于容灾的,读取不了服务器就用这个文件内容,如果你想禁用我可以加一下开关。

from agollo.

eddycjy avatar eddycjy commented on August 17, 2024

@eddycjy 这个文件原意是用于容灾的,读取不了服务器就用这个文件内容,如果你想禁用我可以加一下开关。

是的,我建议加个开关。可能我们有的内部配置信息不大方便展示在文件中

from agollo.

zouyx avatar zouyx commented on August 17, 2024

@eddycjy 你好,我尝试了一下,没出现你提到的问题,你看看步骤和你的是否一样?

  • 使用namespace1 启动agollo,然后获取到value:1
  • 停止程序
  • 将namespace1改成namespace2,启动agollo,获取到value2
    并没有出现停滞60s才能获取到的情况。。。

from agollo.

zouyx avatar zouyx commented on August 17, 2024

@eddycjy 可以,我增加一下。

from agollo.

eddycjy avatar eddycjy commented on August 17, 2024

@zouyx 这我是的演示代码,你可以再看看能不能重现?

背景

在 Apollo 上有一个 AppId 为 ceshi01,存在命名空间 application。而命名空间 server 是不存在的

演示代码

func main() {
	ap := &agollo.AppConfig{
		AppId: "ceshi01",
		Cluster: "default",
		NamespaceName: "application",
		Ip: "localhost:8080",
	}
	agollo.InitCustomConfig(func() (*agollo.AppConfig, error) {
		return ap,nil
	})
	agollo.Start()
	value := agollo.GetStringValue("key01", "1")
	log.Printf("key01: %s", value)

	// ---------

	ap = &agollo.AppConfig{
		AppId: "ceshi01",
		Cluster: "default",
		NamespaceName: "server",
		Ip: "localhost:8080",
	}
	agollo.InitCustomConfig(func() (*agollo.AppConfig, error) {
		return ap,nil
	})
	agollo.Start()
	value = agollo.GetStringValue("key02", "2")
	log.Printf("key02: %s", value)
}

输出结果

1555309809706879510 [Debug] get all server info:[{"appName":"APOLLO-CONFIGSERVICE","instanceId":"10.5.217.8:apollo-configservice:8080","homepageUrl":"http://10.5.217.8:8080/"}]
1555309809715587740 [Info] agollo start finished , error:<nil>
2019/04/15 14:30:09 key01: value01
1555309809718148093 [Debug] get all server info:[{"appName":"APOLLO-CONFIGSERVICE","instanceId":"10.5.217.8:apollo-configservice:8080","homepageUrl":"http://10.5.217.8:8080/"}]
1555309870165188200 [Info] Config Not Modified:<nil>
1555309870165228858 [Info] agollo start finished , error:<nil>
1555309870165242016 [Error] get config value fail!key:key02,err:Entry not found
2019/04/15 14:31:10 key02: 2

from agollo.

zouyx avatar zouyx commented on August 17, 2024

收到,我看看

from agollo.

eddycjy avatar eddycjy commented on August 17, 2024

@zouyx 请问怎么样了呢

from agollo.

zouyx avatar zouyx commented on August 17, 2024

@eddycjy 我想了解一下为什么会有使用不存在的namespace?

如果想要支持多个namespace,目前是暂时不支持的。

from agollo.

eddycjy avatar eddycjy commented on August 17, 2024

@zouyx 有可能会有同事漏配了,导致读取了不存在的 namespace。这报错是没有问题的,但是问题是其需要等待 60s...

from agollo.

zouyx avatar zouyx commented on August 17, 2024
  • -不好意思,没留意到你回复。。。

我的意思是能不能只用存在的namespace?

from agollo.

eddycjy avatar eddycjy commented on August 17, 2024

@zouyx 正式使用肯定是只用已存在的,但这个 issue 探讨的是特殊情况,有人漏配等。这个等待 60s 是 Apollo 本身导致的,还是库里有意为之?

from agollo.

zouyx avatar zouyx commented on August 17, 2024

@eddycjy 该问题的原因在于从你提供的代码层面上来,调用了两次start方法,但是对于底层代码来说,只有一个协程在跑,Apollo和agollo的长轮询间隔是1分钟。

所以,你在启动调用第一个start的时候其实已经启动了协程去访问,只要Apollo没返回错误,agollo都认为是链接成功,在到下一个访问之前执行的代码,只会保存在内存,不会立刻访问。

如果出现这种情况其实有几种解决方案

  • 修改配置文件,重启。
  • 修改配置文件,不重启,进行热更。

你是希望走第二种?

from agollo.

nobodyiam avatar nobodyiam commented on August 17, 2024

对于不存在或没有发布过配置的namespace,如果去long polling的话,在apollo服务端是会hold住60秒的,因为对于long polling的场景,只要该namespace没有变化,就不会产生变化的通知,如果在long polling过程中该namespace发布了配置,那么该long polling会立马返回。

看了下代码,其实在初始化的过程中只需要做加载配置一个动作就可以了(autoSyncConfigServices),long polling这个步骤(notifySyncConfigServices)异步执行即可,不需要在主线程中执行。

from agollo.

stale avatar stale commented on August 17, 2024

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.

from agollo.

debuger6 avatar debuger6 commented on August 17, 2024

@eddycjy 这个文件原意是用于容灾的,读取不了服务器就用这个文件内容,如果你想禁用我可以加一下开关。

你这个文件容不了灾啊,服务器读不了也加载不到该文件,代码有一处bug

from agollo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.