Giter Site home page Giter Site logo

Comments (3)

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

这样处理的原因是不同namespace可能会有相同的key,
导致viper中存储k,v的map相互覆盖,导致配置不对
如果你有不同的namespace我建议是创建多个viper对象分别去加载和读取

from agollo.

1stmud avatar 1stmud commented on May 25, 2024

嗯, 目前是的 直接new多个viper对象
相互覆盖是使用者的问题, 支持不支持是设计问题 ,viper设计支持多次AddRemoteProvider 就说明这个是合理的 ,我只是建议, 大佬可以考虑下 ,你的viper remote方式很棒

from agollo.

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

viper支持多次AddRemoteProvider应该是为了容错之类的
他只会从remoteProviders这个列表中,获取没有出错的那次配置就return
而不会将所有providers配置加载进来,所以即使能传多个namespace也只有其中一个的配置

func (v *Viper) getKeyValueConfig() error {
	if RemoteConfig == nil {
		return RemoteConfigError("Enable the remote features by doing a blank import of the viper/remote package: '_ github.com/spf13/viper/remote'")
	}

	for _, rp := range v.remoteProviders {
		val, err := v.getRemoteConfig(rp)
		if err != nil {
			continue
		}
		v.kvstore = val
		return nil
	}
	return RemoteConfigError("No Files Found")
}

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.