Giter Site home page Giter Site logo

数组问题 about agollo HOT 8 CLOSED

shima-park avatar shima-park commented on May 23, 2024
数组问题

from agollo.

Comments (8)

pengbinbin1 avatar pengbinbin1 commented on May 23, 2024

打印的解析如下 ,不是数组的都解析到了
image

from agollo.

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

你这个用的是properties格式的配置文件吧,properties本身只是key:value没有数组类型
数组这种定义属于自定义的去解析的.

from agollo.

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

我之前去处理这个问题是再封装了一个读取配置的库。可以的话最好是换个配置文件格式。

var i int
var arr []string
for {
    key := fmt.Sprintf("case[%d]", i)
    if viper.IsSet(key) {
        value := viper.Get(key)
        arr = append(arr, value)
        i++
        continue
    }
    break
}

老铁,如果有帮到你记得star

from agollo.

pengbinbin1 avatar pengbinbin1 commented on May 23, 2024

apollo的web界面支持直接导入yaml格式的文件吗,本来是配置文件是yml格式的,导成了prop格式的贴到apollo里的

from agollo.

pengbinbin1 avatar pengbinbin1 commented on May 23, 2024

另外,使用viper的时候,有没有类似于注册一个回调,只要配置有更新就会调用我注册的回调的机制。看例程中有忙轮询和监听两种。监听的那种也是要死循环去不断重新获取的,有没有类似主动通知的那种。不管能不能帮上,start没毛病

from agollo.

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

apollo的web界面支持直接导入yaml格式的文件吗,本来是配置文件是yml格式的,导成了prop格式的贴到apollo里的

支持的只是apollo这个ui做的比较傻,藏的比较深
image
image
namespace如果是public的在界面点public就好来,创建出来就是public的yml/yaml格式的

更便捷的方式你可以用我封装的apollo openapi的sdk去同步配置,而不是手动去copy啥的
之前我们的配置是存在consul后来迁移到了apollo,手动迁移一堆配置又累又不靠谱
https://github.com/shima-park/apollo-openapi

from agollo.

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

另外,使用viper的时候,有没有类似于注册一个回调,只要配置有更新就会调用我注册的回调的机制。看例程中有忙轮询和监听两种。监听的那种也是要死循环去不断重新获取的,有没有类似主动通知的那种。不管能不能帮上,start没毛病

viper本身没有提供事件回调的方法,它属于一种比较上层的封装了,你如果要这个特性的话,可能要fork它做一些功能改造。增加注册Hook方法,在watchKeyValueConfigOnChannel加上调用Hook。

https://github.com/spf13/viper/blob/v1.7.0/viper.go#L1772
getKeyValueConfig读取一次远程配置更新本地维护的kvstore这个map

https://github.com/spf13/viper/blob/v1.7.0/viper.go#L1798
watchKeyValueConfigOnChannel 它这个内部开了goroutine消费更新事件,更新本地维护的kvstore,不再向外传递事件

from agollo.

pengbinbin1 avatar pengbinbin1 commented on May 23, 2024

感谢帮助

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.