pyapollo-config-client 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- apollo_client/__init__.py +92 -0
- apollo_client/_version.py +3 -0
- apollo_client/async_client.py +1595 -0
- apollo_client/cache.py +197 -0
- apollo_client/client.py +1393 -0
- apollo_client/config.py +356 -0
- apollo_client/env.py +85 -0
- apollo_client/errors.py +46 -0
- apollo_client/meta.py +249 -0
- apollo_client/parser.py +239 -0
- apollo_client/py.typed +0 -0
- apollo_client/transport.py +546 -0
- apollo_client/utils.py +61 -0
- pyapollo_config_client-0.2.0.dist-info/METADATA +561 -0
- pyapollo_config_client-0.2.0.dist-info/RECORD +17 -0
- pyapollo_config_client-0.2.0.dist-info/WHEEL +4 -0
- pyapollo_config_client-0.2.0.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Apollo (Ctrip) configuration client for Python.
|
|
2
|
+
|
|
3
|
+
Example
|
|
4
|
+
-------
|
|
5
|
+
>>> from apollo_client import ApolloClient
|
|
6
|
+
>>> client = ApolloClient(
|
|
7
|
+
... app_id="demo-app",
|
|
8
|
+
... config_server_url="http://127.0.0.1:18080",
|
|
9
|
+
... namespaces=["application", "demo.yaml"],
|
|
10
|
+
... )
|
|
11
|
+
>>> client.start()
|
|
12
|
+
>>> client.get_value("app.name")
|
|
13
|
+
'Apollo Python Client'
|
|
14
|
+
>>> client.get_int("server.port", namespace="demo.yaml")
|
|
15
|
+
8080
|
|
16
|
+
|
|
17
|
+
For asyncio applications import ``AsyncApolloClient`` (requires the ``async``
|
|
18
|
+
extra: ``pip install "pyapollo-config-client[async]"``)::
|
|
19
|
+
|
|
20
|
+
from apollo_client import AsyncApolloClient
|
|
21
|
+
|
|
22
|
+
async with AsyncApolloClient(app_id="demo-app", ...) as client:
|
|
23
|
+
client.get_value("app.name")
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
from ._version import __version__
|
|
29
|
+
from .cache import DiskCache
|
|
30
|
+
from .client import WATCH_MODES, ApolloClient, ChangeListener
|
|
31
|
+
from .config import (
|
|
32
|
+
SUPPORTED_FORMATS,
|
|
33
|
+
ChangeEvent,
|
|
34
|
+
ConfigChange,
|
|
35
|
+
NamespaceConfig,
|
|
36
|
+
detect_format,
|
|
37
|
+
diff_configs,
|
|
38
|
+
diff_mappings,
|
|
39
|
+
flatten_mapping,
|
|
40
|
+
)
|
|
41
|
+
from .env import options_from_env
|
|
42
|
+
from .errors import (
|
|
43
|
+
ApolloAuthError,
|
|
44
|
+
ApolloConnectionError,
|
|
45
|
+
ApolloError,
|
|
46
|
+
ApolloHTTPError,
|
|
47
|
+
ApolloParseError,
|
|
48
|
+
NamespaceNotFoundError,
|
|
49
|
+
)
|
|
50
|
+
from .meta import MetaServerResolver, parse_meta_response
|
|
51
|
+
from .parser import parse_content, parse_json, parse_properties, parse_yaml
|
|
52
|
+
|
|
53
|
+
__all__ = [
|
|
54
|
+
"SUPPORTED_FORMATS",
|
|
55
|
+
"WATCH_MODES",
|
|
56
|
+
"ApolloAuthError",
|
|
57
|
+
"ApolloClient",
|
|
58
|
+
"ApolloConnectionError",
|
|
59
|
+
"ApolloError",
|
|
60
|
+
"ApolloHTTPError",
|
|
61
|
+
"ApolloParseError",
|
|
62
|
+
"ChangeEvent",
|
|
63
|
+
"ChangeListener",
|
|
64
|
+
"ConfigChange",
|
|
65
|
+
"DiskCache",
|
|
66
|
+
"MetaServerResolver",
|
|
67
|
+
"NamespaceConfig",
|
|
68
|
+
"NamespaceNotFoundError",
|
|
69
|
+
"__version__",
|
|
70
|
+
"detect_format",
|
|
71
|
+
"diff_configs",
|
|
72
|
+
"diff_mappings",
|
|
73
|
+
"flatten_mapping",
|
|
74
|
+
"options_from_env",
|
|
75
|
+
"parse_content",
|
|
76
|
+
"parse_json",
|
|
77
|
+
"parse_meta_response",
|
|
78
|
+
"parse_properties",
|
|
79
|
+
"parse_yaml",
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
_LAZY_ASYNC_NAMES = {"AsyncApolloClient", "AsyncApolloTransport", "AsyncChangeListener"}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def __getattr__(name: str):
|
|
86
|
+
"""Import the optional asyncio API only when it is actually requested."""
|
|
87
|
+
|
|
88
|
+
if name in _LAZY_ASYNC_NAMES:
|
|
89
|
+
from . import async_client
|
|
90
|
+
|
|
91
|
+
return getattr(async_client, name)
|
|
92
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|