config_util
config_util 配置热加载
1 获取 py 格式配置文件
配置文件示例(butterfly/conf/servicer/demo_servicer.py)
host = "127.0.0.1"
port = 8080
name = "ffff"
bj = {
"host": "127.0.0.2",
"port": 8081,
}
from xlib.util import config_util
ip = "0.0.0.0"
reqid = "DEV_CESHI"
wsgienv = {"PATH_INFO": "/echo"}
req = httpgateway.Request(reqid, wsgienv, ip)
# "127.0.0.1"
print(config_util.get_config(req, "demo_servicer", "host"))
req.idc = "bj"
# "127.0.0.2"
print(config_util.get_config(req, "demo_servicer", "host"))
print(config_util.get_config(req, "demo_servicer", "name"))
print(config_util.get_config(None, "demo_servicer", "name"))2 获取 toml 格式配置文件
配置文件示例(butterfly/conf/servicer/demo_servicer.toml)
3 获取特定目录下配置
Last updated