apopy: Simple Apollo Config Client for Python. 
pip install apopy
Quick Start
[!NOTE]
- 示例里的配置信息仅供测试使用,请勿用于生产环境。
- 具体的配置可能会变动,仅用于说明使用方法,具体的访问方式见 https://www.apolloconfig.com/#/zh/README
from apopy import Client, NamespaceType
client = Client(
config_server_url="http://81.68.181.139:8080",
app_id="apollo-common",
cluster_name="default",
secret="5fdc723621054e0f945cb441561687eb",
ip="192.168.1.4",
)
# 读取 Namespace 为 application 的配置(接口带缓存)
print(client.read_namespace_with_cache(namespace="application"))
# 读取 Namespace 为 application 的配置(接口无缓存)
print(
client.read_namespace_without_cache(
namespace="application", namespace_type=NamespaceType.PROPERTIES
)
)
# 读取配置
print(client.get("test"))
配置轮训更新
Apopy 提供了内置的针对单独 namespace 配置轮训更新功能,可以通过以下方式实现:
[!WARNING]
Apopy 本身并没有配置单独的线程锁/进程锁,如果真的需要异步订阅更新, 请根据自己的需求在外层加上锁保护。
import time
import threading
def start_background_update(client: Client):
def _update():
while True:
try:
client.read_notification_and_update(
namespace="application", namespace_type=NamespaceType.PROPERTIES
)
except Exception:
pass
finally:
time.sleep(3)
t = threading.Thread(target=_update)
t.start()
start_background_update(client)
while True:
print(client.read_namespace_with_cache(namespace="application"))
time.sleep(5)
Metadata
Release files for apopy 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| apopy-0.1.6.tar.gz | 11.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| apopy-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.9 kB
Release files / apopy-0.1.6.tar.gz
| Download URL | apopy-0.1.6.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03af71a6e072f4ac239c42a63b8fdd026f557a152c8864317603ba7d991ab8a5
|
|
BLAKE2b-256 checksum How to use checksums |
db0ca19fd2781b7734dcbca9875d22b9cc3af993ad348323063e8db2a2f3c40b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.4.26
|
Release files / apopy-0.1.6-py3-none-any.whl
| Download URL | apopy-0.1.6-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b54cf931c60ed0d07dd15b3670d8fc32efdf992a09173d20e1509789085e58be
|
|
BLAKE2b-256 checksum How to use checksums |
1735b1c11ae2abdb5dfbdfe4dfaa9c70cc97bfd6a276ad8560fb1c3b66e7c7ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.4.26
|
Security for apopy 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.