Giter Site home page Giter Site logo

Comments (5)

shima-park avatar shima-park commented on May 25, 2024

修改apollo的配置后,有没有发布配置

from agollo.

MisterChing avatar MisterChing commented on May 25, 2024

修改apollo的配置后,有没有发布配置

有发布。不修改apollo配置。在select中也只能打印出最初的一次值

from agollo.

shima-park avatar shima-park commented on May 25, 2024

可以加入日志的参数选项,开启日志,看看具体出现了什么异常。

agolloClient, err := agollo.New(
        "localhost:8080",
        "SampleApp",
        agollo.WithLogger(agollo.NewLogger(agollo.LoggerWriter(os.Stdout))),
        agollo.AutoFetchOnCacheMiss(),
        agollo.PreloadNamespaces("application", "TEST1.json"),
    )

我用上面你给的代码,测试过了是可以的。你再检查下namspace的名字是否正确。

package main

import (
	"fmt"
	"os"
	"time"

	"github.com/shima-park/agollo"
)

func main() {
	agolloClient, err := agollo.New(
		"localhost:8080",
		"SampleApp",
		agollo.WithLogger(agollo.NewLogger(agollo.LoggerWriter(os.Stdout))),
		agollo.AutoFetchOnCacheMiss(),
		agollo.PreloadNamespaces("test.json", "TEST1.json.json"),
	)
	if err != nil {
		panic(err)
	}

	fmt.Println(agolloClient.GetNameSpace("TEST1.json.json"), agolloClient.GetNameSpace("test.json"))
	errChan := agolloClient.Start()
	watchChan := agolloClient.Watch()
	ticker := time.NewTicker(5 * time.Second)
	for {
		select {
		case <-ticker.C:
			fmt.Println("Ticker:",
				"TEST1.json.json", agolloClient.GetNameSpace("TEST1.json.json"), "\n",
				"test.json", agolloClient.GetNameSpace("test.json"),
			)
		case err := <-errChan:
			fmt.Println(err, 0)
		case resp := <-watchChan:
			fmt.Println("Notify:", resp, 0)
		}
	}
}

image

我在测试的时候就碰到一个坑
image

图中第二个namespace: TEST1.json 实际namespace是 TEST1.json.json
后面两个namespace: test.json, test.yaml

from agollo.

MisterChing avatar MisterChing commented on May 25, 2024

我尝试加了日志,还是不正常。能监听到了,但值没有被修改

Xnip2020-11-13_17-56-57

from agollo.

shima-park avatar shima-park commented on May 25, 2024

Screenshot_20201113_184300

你就用我上一个回复贴的示例代码,改成你的配置试试看。
还有库的tag你看是不是最新的版本v1.2.7

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.