Skip to main content

A simple python library for apollo config client.

Project description

安装


pip install apollo-client

使用


app_id = 'demo-service'
config_url = 'http://127.0.0.1:8080'
cluster = 'default'
secret = ''
env = 'DEV'

client = ApolloClient(app_id=app_id, config_url=config_url, cluster=cluster, secret=secret, env=env)
lm_API_KEY = client.get_value("lm_API_KEY")

也默认支持通过环境变量来传递值,基本和 Java 客户端保持一致

环境变量 对应的字段
APP_ID app id 应用名
IDC cluster 集群名
|ENV| 环境 默认(DEV)|
APOLLO_ACCESS_KEY_SECRET 访问密钥
CLIENT_IP 默认会自己获取,但是也可以支持自己传递
APOLLO_CACHE_PATH 配置缓存路径
APOLLO_META config url

如果环境中存在 ENV的环境变量, 如 ENV=DEV。则优先组合出 DEV_META 这个环境变量名称来获取 config url。 如果该环境变量不存在,则取 APOLLO_META 环境变量的值。如果 APOLLO_META 也不存在,则使用代码定义的 config_url 的值。

其它环境变量同理,以此类推。

热更新

默认会启动一个线程来定时更新本地缓存的配置,所以,如果每次用的是 get_value 来获取配置,可以实现配置热更新。

License


This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apollo_python-1.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

apollo_python-1.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file apollo_python-1.1.0.tar.gz.

File metadata

  • Download URL: apollo_python-1.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for apollo_python-1.1.0.tar.gz
Algorithm Hash digest
SHA256 da7f5968040d6e42c0355b5d7bc01728a4a448409c400a8e8a74cdf2a6f7c3c6
MD5 8526c96716c6264a4531d7428f940480
BLAKE2b-256 7716f52866d7537d1f9e0c4cd28d1aeea08890a9a65b6af4566ba8f8c3e11f33

See more details on using hashes here.

File details

Details for the file apollo_python-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for apollo_python-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f051877f4eb0cc8654e460228d114652d27dc2d5c985969f3886d4cb9461e68
MD5 84f4bdcf937e8f1c67e886f8a0b71ce4
BLAKE2b-256 978cd90ec661ed5dce7ca3fd70f112e679ae437cacdba253e6a8894d5430f3ba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page