Giter VIP home page Giter VIP logo

Comments (3)

kaelzhang avatar kaelzhang commented on September 22, 2024 1

对的,在项目启动的时候,为不同的环境,传递不同的 apollo server url 的值即可。

Apollo 就是把一系列配置,变成 apollo server url 这一个配置的过程。

如果用 docker (或k8s),只需要配置一个 ENV 即可。

显然配置这个 ENV 不是 ctrip-apollo 应该做的

from ctrip-apollo.

kaelzhang avatar kaelzhang commented on September 22, 2024

What do you mean by Apollo env?

And can you describe what your problem is?

from ctrip-apollo.

shinux avatar shinux commented on September 22, 2024

背景是我也在开发一个适用于我司中间件逻辑的 node 和 python Apollo client,所以参考了一下您的库

我理解中的 Apollo 是这样分级/层的(不知道不对,文档

app (app id)
  \-+= env (apollo server url)
     \-+= cluster ( cluster name)
        \-+= namespace (namespace name)
          \-+= configs....       

其中 java sdk 应该会通过以下几种方式区分 env

Environment可以通过以下3种方式的任意一个配置:

通过Java System Property

可以通过Java的System Property env来指定环境
在Java程序启动脚本中,可以指定-Denv=YOUR-ENVIRONMENT
如果是运行jar文件,需要注意格式是java -Denv=YOUR-ENVIRONMENT -jar xxx.jar
注意key为全小写
通过操作系统的System Environment

还可以通过操作系统的System Environment ENV来指定
注意key为全大写
通过配置文件

最后一个推荐的方式是通过配置文件来指定env=YOUR-ENVIRONMENT
对于Mac/Linux,文件位置为/opt/settings/server.properties
对于Windows,文件位置为C:\opt\settings\server.properties

显然 ctrip-apollo 和 apollo-declare 都不支持这些。


后来仔细想了一下,感觉 node client 也未必要像 java 一样留出专门的接口区分这个东西。

ENV 的意义其实只是区分和指定 apollo server url。一个应用在一台服务器上通常是固定的 env。如果一定要区分 env 参数只需要在实例化时像 cluster 、namespace 一样传入特定的 apollo server url 就可以了,至于调用者在传入之前是通过写死环境文件还是在 progress on 时指定环境还是从什么地方来的,不是很重要。

from ctrip-apollo.

Related Issues (11)

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.