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.
@@ -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}")
@@ -0,0 +1,3 @@
1
+ """Package version (kept separate to avoid import cycles)."""
2
+
3
+ __version__ = "0.2.0"