Skip to main content

python apollo config

Project description

携程 Apollo(阿波罗) 配置库

说明

这是一个携程 Apollo(阿波罗) 配置获取库,支持环境变量和用户自定义配置。

配置优先级(可通过参数控制):环境变量 > 阿波罗 > 自定义

链接

安装

pip install py-apollo-config

依赖

pip install config-registry
pip install py-apollo-client

使用

初始化:

import os

from ApolloClient import ApolloClient
from ApolloConfig import ApolloConfig
from ConfigRegistry import ConfigRegistry

os.environ.setdefault('ENV_PREFIX_APOLLO', 'apollo')
os.environ.setdefault('APOLLO_URI', 'http://192.168.68.251:8080')
os.environ.setdefault('APOLLO_APPID', 'equipment-services')

config = ApolloConfig(prefix='{环境变量前缀}')
#config.setting = ConfigRegistry()
#config.apollo = ApolloClient()
config.init()

获取配置:

config.get('debug', default=False, apollo=False, env=Fals)

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

py-apollo-config-1.1.2.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

py_apollo_config-1.1.2-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

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