Comments (3)
对的,在项目启动的时候,为不同的环境,传递不同的 apollo server url 的值即可。
Apollo 就是把一系列配置,变成 apollo server url 这一个配置的过程。
如果用 docker (或k8s),只需要配置一个 ENV 即可。
显然配置这个 ENV 不是 ctrip-apollo
应该做的
from ctrip-apollo.
What do you mean by Apollo env
?
And can you describe what your problem is?
from ctrip-apollo.
背景是我也在开发一个适用于我司中间件逻辑的 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)
- coverage HOT 1
- 支持多个namespace HOT 1
- The file format of the local cache file can be customized
- The dependency `request` has been deprecated
- 4.0.0: Redesign APIs
- Demo with SyntaxError: await is only valid in async function HOT 4
- Should use getConfigFile for JSON format
- const {DEFAULT_POLLING_RETRY_POLICY} = require('./polling') DEFAULT_POLLING_RETRY_POLICY值为undefined。为什么要使用呢? HOT 1
- Cann't get json config
- 建议支持1.6.0后版本增加的密钥启用 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ctrip-apollo.